【问题标题】:issue while sending mail using php mailer使用php mailer发送邮件时出现问题
【发布时间】:2012-03-21 07:26:36
【问题描述】:

我已经使用 php mailer 类发送了一封电子邮件。邮件发送成功,但我收到的邮件内容为“logo 1”。我正在使用以下代码..请任何人帮助

<?
include_once 'editors/tinymce.php';
$to = 'test@test.com';
$frm = 'test1@test1.com';
$sub = 'Weekly Working Report';

$mail_body = include_once('mail_content.php');
$mailstatus = l_mail('', '', $to, '', $frm, '', $sub, $mail_body);

if ($mailstatus == 'ok') {
    echo '<center><font color=red style="font-size:14px">Message has been sent Succesfully.....!</font></center><br>';
} else {
    echo $mailstatus;
}
?>

【问题讨论】:

  • main_content.php 的内容是什么?
  • I "+1" 此评论:如果您的邮件发送正确,则您的问题与内容有关。如果您忘记添加 html 标头,也可能是 HTML 问题

标签: php phpmailer


【解决方案1】:

你不应该写成$mail_body = include_once('mail_content.php'); 相反,

include_once 'editors/tinymce.php';
$to = 'test@test.com';
$frm = 'test1@test1.com';
$sub = 'Weekly Working Report';

    ob_start(); // start output buffering
    include_once('mail_content.php');
    $mail_body = ob_get_contents(); // get the contents from the buffer
    ob_end_clean();

$mailstatus = l_mail('', '', $to, '', $frm, '', $sub, $mail_body);

if ($mailstatus == 'ok') {
    echo '<center><font color=red style="font-size:14px">Message has been sent Succesfully.....!</font></center><br>';
} else {
    echo $mailstatus;
}

【讨论】:

    【解决方案2】:
    $to = "pbvamsi@gmail.com";
     $subject = "Hey keep belief in me!";
     $body = "Hi,\n\nHow are you?\n\n be good do good";
     $header="god@heaven.com";
     if (mail($to, $subject, $body, $header)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
      }
    

    我希望这有效

    【讨论】:

      【解决方案3】:

      在创建 phpmailer 类的对象时使用下面的代码

      $mail = new phpmailer();
      $mail->IsHTML(true);
      

      谢谢

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-07
        • 1970-01-01
        • 1970-01-01
        • 2011-01-30
        • 2011-03-28
        • 2010-11-20
        相关资源
        最近更新 更多