Get Email To Receiver When Submitted And Also Sender Get Submission Copy using PHPMailer

孤街醉人 提交于 2019-12-24 18:37:12

问题


I am newbie with PHPMailer library , I want to get emails from my contact form But on submission of form I want sender also get a copy of mail With additional message as " thanks for registering with us." As I gone through PHP mailer examples We can use addCC();. But how to embed additional msg.

Could you please help me with this ?


回答1:


Using CC or BCC will always result in identical message being sent to all; If you want the messages to be different for different recipients, you must send separate messages with different bodies. With PHPMailer:

$mail->addAddress('recipient1@example.com');
$mail->Body = "hello abc";
$mail->send();
$mail->clearAddresses();
$mail->addAddress('recipient2@example.com');
$mail->Body = "hello xyz";
$mail->send();

It's important to call clearAddresses as otherwise the second message will be sent to both recpients.



来源:https://stackoverflow.com/questions/47631874/get-email-to-receiver-when-submitted-and-also-sender-get-submission-copy-using-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!