繁体   English   中英

CC电子邮件将不会使用PEAR发送

[英]The CC email will not send using PEAR

我已经阅读过有关此问题的类似文章,但无法完全理解我在这里做错了什么。 可以很好地收到“收件人”电子邮件。

但是,使用以下脚本时,我无法发送“ CC”电子邮件。 任何帮助将非常感激。

// Require Pear Mail Packages 
require_once ("Mail.php"); 
require_once ("Mail/mime.php");
require_once ("Mail/mail.php");

$crlf = "\n"; 
$from = "Company <admin@example.com>";
$to =  $purchasersName . "<" . $purchasersEmail . ">";
$cc = "Company <admin@example.com>";
$subject = "Company Order Confirmation";

$host = "localhost";
$port = "25";
$username = "the username";
$password = "the password";

$hdrs = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Subject' => $subject);

$mime = new Mail_mime(array('eol' => $crlf));
$mime->setHTMLBody($mailBody);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$smtp =& Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $hdrs, $body);

此评论在此页的梨文档中

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

(如果您需要其他选项,则可以尝试http://swiftmailer.org ,我现在已经在许多项目中使用了它)

注释:arminfrey@gmail.com 2007-07-08 05:13 UTC为了使用smtp向cc或bcc发送电子邮件,您必须将cc电子邮件地址都列为收件人(这决定了电子邮件在哪里-mail发送)并在cc标头中,该标头告诉邮件客户端如何显示它。

这是我使用的代码:

$ to ='to@example.com'; $ cc ='cc@example.com';

$ recipients = $ to。“,”。$ cc;

$ headers ['From'] ='from@example.com'; $ headers ['To'] = $ to; $ headers ['Subject'] ='测试消息'; $ headers ['Cc'] ='cc@example.com'; $ headers ['Reply-To'] ='from@example.com';

$ send = $ mail-> send($ recipients,$ headers,$ body);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM