AddBCC-phpmailer.php

时间:2018-09-06 10:23:19

标签: php codeigniter phpmailer

我想在项目中使用BCC功能发送电子邮件,并且我使用的是'PHPMailer'库版本-5.2.7和PHP版本为5.5.9,除了BCC邮件外,它的工作原理还不错。我不知道为什么,他们没有错误: 邮件将发送到TOCC,但不会发送到BCC

我正在使用的代码如下:

    //require 'PHPMailerAutoload.php';
require_once APPPATH.'third_party/smtp/PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();


$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = SMTP_HOST;
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = SMTP_PORT;
//Whether to use SMTP authentication
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = SMTP_CRYPTO;
//Username to use for SMTP authentication
$mail->Username = SMTP_USER;
//Password to use for SMTP authentication
$mail->Password = SMTP_PASS;
//Set who the message is to be sent from
$mail->setFrom( $from_email , $from_name );
//Set an alternative reply-to address
$mail->addReplyTo( $from_email , $from_name );
//Set who the message is to be sent to
$mail->addAddress( $to , $subject );
//$mail->addAddress('example@hotmail.com', 'This is a subject Ultimate 11');
$mail->addBCC('test@example.com', 'Test');

//Set the subject line
$mail->Subject = $subject;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML( $message );
//Replace the plain text body with one created manually
// $mail->AltBody = 'This is a plain-text message body';

//send the message, check for errors
$mail->send();

0 个答案:

没有答案