我有一个发送电子邮件的表单,我想在邮件中添加一封cc电子邮件。请告诉我如何使用下面的行来完成此操作。感谢
mail("mainemail@email.com;CCemail@email.com", $subject, $message, $header);
答案 0 :(得分:0)
public function SMTPClient($subject,$content,$instance) {
try {
$mailer = new PHPMailer(true);
$mailer->IsSMTP();
$mailer->SMTPDebug = 1;
$mailer->SMTPAuth = def_SMTP_AUTHENTICATION; // enable SMTP authentication
$mailer->SMTPSecure = def_SMTP_SECURE; // sets the prefix to the servier
$mailer->Host = def_SMTP_SERVER; // sets GMAIL as the SMTP server
$mailer->Port = def_SMTP_PORT; // set the SMTP port for the GMAIL server
$mailer->Username = def_SMTP_USERNAME; // GMAIL username
$mailer->Password = def_SMTP_PASSWORD; // GMAIL password
$mailer->SetFrom(def_MAIL_FROM_ADDRESS, def_MAIL_FROM_NAME);
$to = def_MAIL_TO;
$mailer->AddAddress($to);
$mailer->Subject = $subject;
$mailer->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mailer->WordWrap = 80; // set word wrap
$mailer->AddCC('xzy@gmail.com', 'xyz');
$mailer->AddReplyTo(def_MAIL_TO, 'abc');
$mailer->MsgHTML($content);
$mailer->IsHTML(true); // send as HTML
$mailer->Send();
$this->logger("Message has been sent Successfully","INFO",$instance);
echo 'Message has been sent Successfully.';
} catch (phpmailerException $e) {
echo $e->errorMessage()`enter code here`;
}
}
Note:Use the mailer component from http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/detail?name=PHPMailer_5.2.4.zip&can=2&q=