1

我正在尝试在 linux 平台上使用 php 邮件功能发送 html 图像邮件。当我尝试发送简单的 html 内容然后它成功地传递给它的订阅者时,有一个问题。但是当我尝试发送包含少量图像的电子邮件时,它无法发送。下面是两个代码 1 通过它们传递简单的 html。2 没有发货。

<?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" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>

代码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: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

    //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....!";
?>
4

1 回答 1

2

我更正了我能够发送图像邮件的代码,下面是代码:

<?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' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'From: <centos_test@example.com>' . "\r\n";


mail($to,$sub,$msg,$headers);
?>

我仍在努力发送高度定制的邮件,一旦我发现它是如何完成的,我将描述它是如何实现的。

于 2013-09-28T19:16:37.483 回答