我在实时服务器中使用phpmailer为发件人和收件人发送电子邮件。它工作正常,但我想在发件人副本中包含额外的消息“感谢您注册我们”。我无法做到。 你能帮忙吗? 代码我尝试到目前为止:
<?php
$msg = "";
if (isset($_POST['submit'])) {
require 'phpmailer/PHPMailerAutoload.php';
function sendemail($to, $from, $fromName, $body) {
$mail = new PHPMailer();
$mail->setFrom($from, $fromName);
$mail->addAddress($to);
$mail->Subject = 'Contact Form - Email';
$mail->Body = $body;
$mail->isHTML(false);
return $mail->send();
}
function sender_mail($to, $from, $fromName, $body) {
$mail = new PHPMailer();
$mail->setFrom($from, $fromName);
$mail->addAddress($to);
$mail->Subject = 'Copy Contact Form - Email';
$mail->Body = $body . 'Thanks for registering with us';
$mail->isHTML(false);
return $mail->send();
}
$name = $_POST['username'];
$email = $_POST['email'];
$body = $_POST['body'];
sendemail('abc@domain.com', 'xyz@domain.com', $name, $body);
sender_mail('abc@domain.com', $email, $name, $body);
}?>
答案 0 :(得分:0)
我总是创建不同的邮件对象来发送另一封电子邮件。所以它总是会选择新的消息。
要发送其他电子邮件,您可以更新如下:
isLocationOnPath
第二个选项是在第二封电子邮件上方使用 $mail2 = new PHPMailer();
$mail2->setFrom($from, $fromName);
$mail2->addAddress($to);
$mail2->Subject = 'Copy Contact Form - Email';
$mail2->Body = $body . 'Thanks for registering with us';
$mail2->isHTML(false);
return $mail2->send();
清除您之前的消息,如下所示:
clearAddresses