我对 PHP MAILER 函数有疑问。我正在使用 GMAIL SMTP 身份验证来发送电子邮件,并且它工作正常,但我想设置“发件人”电子邮件,如“myid@domainname.com”,但它不能正常工作。
我使用下面的代码来设置“发件人”电子邮件
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.gmail.com"; // SMTP server
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "test@gmail.com"; // GMAIL username
$mail->Password = "test@123";
$mail->SetFrom("myid@domainname.com","Domian");
它向我显示默认电子邮件 test@gmail.com 而不是 myid@domainname.com
请帮帮我。
提前致谢!