I am trying to retrieve email using php mail but i am unable to recieve Inline images. I am able to recieve text but not recieved images.
Below is code i have tried :
<?php
$emailAddress = "domain@domian.com";
$emailPassword = "password";
$domainURL = 'domian.com';
$useHTTPS = true;
$inbox = imap_open('{'.$domainURL.':143/notls}INBOX',$emailAddress,$emailPassword) or die('Cannot connect to domain:' . imap_last_error());
$emails = imap_search($inbox,'UNSEEN');
if($emails) {
rsort($emails);
foreach($emails as $email_number) {
$overview = imap_fetch_overview($inbox,$email_number,0);
$header = imap_headerinfo($inbox, $email_number);
echo $subject_other= $overview[0]->subject;
echo $sender_name_other= $overview[0]->from;
echo $date_other=$overview[0]->date;
echo $msg_to_other=$overview[0]->to;
echo $msg_from_other = $header->from[0]->mailbox . "@" . $header->from[0]->host;
$message = imap_fetchbody($inbox, $email_number, 2);
echo $message;
}
}
imap_close($inbox);
?>
only receive text mail, cannot receive inline images how to fix it...please help me...
You need to specify header for sending images in mail.
You cannot display images on text/plain emails as shown above. You must send it as text/html.
So you first have to extend your headers like this:
$header = "From: $noreply@intaxfin.com
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
";
Then you must update your mailcontent replacing or linebreaks with html tags
<br>
or even <p>
Then you also can include image tags having the image you want to show in the email
<img src="http://www.yourserver.com/myimages/image1.jpg">
This will be downloaded from your webserver when recipient opens it.
.
BUT the much better way will be to use phpMailer Class
Using this, you will be able to include any images IN your email, without need to download it from any website. It is easy to learn and absolutely customizable.
By the way: You should use quotation marks for your $body and $body2 values...
$body= "<<<EOD
Contact Form Details of $nameFeild
Name: $nameFeild
City: $cityFeild
Country: $countryFeild
"
@Thiyaga rajan it seems that your image is sending as attachment. Use Base64_encryption
this may work in your case.