douxunnian0423
douxunnian0423
2014-03-24 07:22
浏览 273
已采纳

使用SMTP发送邮件时使用Cc和Bcc的问题 - PHP

I'm sending email from my php page using SMTP. everything works perfect except Bcc.

This is how I got my email, Interestingly I can see bcc as well. enter image description here

Whats wrong in my code, can anyone please help.

$Headers = array("MIME-Version"=> '1.0', 
"Content-type" => "text/html; charset=iso-8859-1",
"From" => $From,
"To" => $To, 
"Bcc" => $User_copy,
"Reply-To" => $From,
"Subject" => $Subject);

$SMTP = Mail::factory('smtp', array ('host' => $Host, 'auth' => true, 'username' => $Username, 'password' => $Password)); 
$mail = $SMTP->send($To, $Headers, $Message);
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duan0504
    duan0504 2014-03-24 20:25
    已采纳

    Diagnose:
    Your mail server does not strip Bcc: headers.

    Fix:
    Do not specify bcc recipients in BCC: headers.
    Add the bcc recipients to first parameter of send.

    http://pear.php.net/manual/en/package.mail.mail.send.php

    点赞 评论
  • douningqiu4991
    douningqiu4991 2014-03-24 19:50

    Try this.

    $To=(string)$SendToEmail ;
    $bcc = "WEBMASTERS_EMAIL_ADDRESS";
    $recipients = $To.",".$bcc;
    $headers["From"] = "who@whatever";
    $headers["To"] = $To;
    $headers["Reply-To"] = $visitormail;
    $headers["Subject"] = $subject;
    $mailmsg = $message;
    /* SMTP server name, port, user/passwd */
    $smtpinfo["host"] = "YOURSITEMAILSERVER.whatever";
    $smtpinfo["port"] = "25";
    $smtpinfo["auth"] = true;
    $smtpinfo["username"] = "Emailaddress@YOURSITEMAILSERVER.whatever";
    $smtpinfo["password"] = EMAIL_PASSWORD";
    /* Create the mail object using the Mail::factory method */
    $mail_object =& Mail::factory("smtp", $smtpinfo);
    /* Ok send mail */
    $mail_object->send($recipients, $headers, $mailmsg);
    
    点赞 评论

相关推荐