I have an PHP code to send email to, cc & bcc.
In this case, the cc is not working. I tested it and saw on my email there is no cc email. (BCC email is worked)
Here is my code:
require_once "Mail.php";
$from = "WEBAPPS <[email protected]>";
$subject = "Calibration will be expiring!";
$host = 'smtp.office365.com';
$port = '587';
$username = 'donotreply@test';
$password = 'w00ew?';
$to = "[email protected]";
$cc = "[email protected]";
$bcc = "[email protected]";
$body = "aa";
$headers = array(
'Port' => $port,
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html; charset=UTF-8'
);
$recipients = $to.", ".$cc.", ".$bcc;
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($recipients, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
Why CC is not working? and how to solve it?
The carbon copy is an header. All recipients are recipients in the same way for the mail server, the difference between carbon copy and blind carbon copy is just a matter of declaring it in the headers.
$headers = array(
'Port' => $port,
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html; charset=UTF-8',
'Cc' => $cc
);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加