i am trying to send html image mailer using php mail function on linux platform. There is one issue when i am trying to send simple html content then it successfully get delivered to its subscriber. but when i try to send emailer which contains few images then it fails to deliver it. below are two codes 1 by which simple html is delivered. 2 which is not getting delivered.
<?php $to = "somebody@example.com, somebodyelse@example.com"; $subject = "HTML email"; $message = " <html> <head> <title>HTML email</title> </head> <body> <p>This email contains HTML Tags!</p> <table> <tr> <th>Firstname</th> <th>Lastname</th> </tr> <tr> <td>John</td> <td>Doe</td> </tr> </table> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "rn"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "rn"; // More headers $headers .= 'From: <webmaster@example.com>' . "rn"; $headers .= 'Cc: myboss@example.com' . "rn"; mail($to,$subject,$message,$headers); ?>
code 2:
<?php //change this to your email. $to = "abhinav@xyz.in"; $from = "abhinav.1@gmail.com"; $subject = "Hello! This is HTML email"; //begin of HTML message $message= <<<EOF <html> <body bgcolor="#DCEEFC"> <center> <b>Looool!!! I am reciving HTML email......</b> <br> <font color="red">Thanks Mohammed!</font> <br> <a href="http://www.maaking.com/">* maaking.com</a> </center> <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine </body> </html> EOF; //end of message $headers = "From: $fromrn"; $headers .= "Content-type: text/htmlrn"; //options to send to cc+bcc //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($to, $subject, $message, $headers); echo "Message has been sent....!"; ?>
Advertisement
Answer
I corrected the code by which I am able to send image mailer below is the code:
<?php $to= 'abhinav@xyz.com' . ','; $to .= 'abhinav@gmail.com'; $sub='test1'; $msg= <<<EOF <html> <body> <table> <tr> <td><img src="http://d32vlg867bsa1v.cloudfront.net/z/prod/w/2/i/zovi-logo2.png" /> </td> </tr> </table> </body> </html> EOF; $headers = 'MIME-Version: 1.0' . "rn"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn"; // Additional headers $headers .= 'From: <centos_test@example.com>' . "rn"; mail($to,$sub,$msg,$headers); ?>
I am still working to sent highly customized mailer and will describe how it can once I found how it can be done.