jeeva Posted October 16, 2007 Share Posted October 16, 2007 hi frnds, can i send email with image using mail function? i tried but i not able to get that image.... Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/ Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 remember your need to attach the image, or have a full URL to its location on your site (better option), also the mail must be HTML format not text.. do you have some sample code, so show ? Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-370579 Share on other sites More sharing options...
jeeva Posted October 16, 2007 Author Share Posted October 16, 2007 thanks MadTechie, actually i dont want to attach the file i want send the mail with company logo...that is wt i am trying.... here is my code <?php $subject="hi"; $message="<table border=1><tr><td>hi this is test mail</td></tr></table>"; $to="[email protected]"; //$from=str_replace(" ","",$fromAdd); $from="jeeva"; //ini set for mail ini_set("SMTP",$server); //ini_set("sendmail_from",$from); //set the html header $femail = "From: $from<$to>"; $cc="Cc:[email protected]"; $remail = "Reply-To: $from<$to>"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $mail=mail($to,$subject,$message,$headers); ?> Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-370593 Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 Assuming, the table works i don't see any image link.. try this, update the http://domain.com/test/jpg <?php $subject="hi"; $message="<table border=1><tr><td>hi this is test mail</td></tr></table> <img scr=\"http://domain.com/test/jpg\"> "; $to="[email protected]"; //$from=str_replace(" ","",$fromAdd); $from="jeeva"; //ini set for mail ini_set("SMTP",$server); //ini_set("sendmail_from",$from); //set the html header $femail = "From: $from<$to>"; $cc="Cc:[email protected]"; $remail = "Reply-To: $from<$to>"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $mail=mail($to,$subject,$message,$headers); ?> EDIT: oops. forgot to escaped the quote Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-370608 Share on other sites More sharing options...
jeeva Posted October 17, 2007 Author Share Posted October 17, 2007 sorry MadTechie, its not working at all.. Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-371346 Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 OK a simple test <?php $from = "[email protected]"; $to = "[email protected]"; $subject = "Testing"; $body = "This is a <b>test</b> <img scr=\"http://domain.com/test.jpg\">"; $plainbody = strip_tags($body); $headers = "From: $from\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $boundary = uniqid(md5(time)); $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; $headers .= "This is a MIME encoded message.\r\n\r\n"; //plain text version of message $headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($plainbody)); //HTML version of message $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($body)); //send message mail($to, $subject, "", $headers); ?> Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-371569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.