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.... Quote 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 ? Quote 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="xxxx@xx.com"; //$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:xxx@xx.com"; $remail = "Reply-To: $from<$to>"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $mail=mail($to,$subject,$message,$headers); ?> Quote 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="xxxx@xx.com"; //$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:xxx@xx.com"; $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 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.. Quote 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 = "tester@domain.com"; $to = "test@domain.com"; $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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73462-mail-with-image/#findComment-371569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.