【发布时间】:2015-11-11 08:42:53
【问题描述】:
我正在使用 phpmailer 从我的在线网站发送电子邮件。但是当我发送它时会显示来自地址的默认服务器地址
<?php
require_once 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddAddress('to@domain.com', 'Jo');
$mail->SetFrom('info@mydomain.com', 'Info');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML('Helooo');
$mail->Send();
echo "Message Sent OK<p></p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
现在显示像
我想将红色标记的地址替换为info@mydomain.com....我该怎么做...这个红色标记的地址是我认为的默认服务器地址。我尝试使用标签中的 phpmailer 设置地址,但没有改变
【问题讨论】:
-
尝试此页面上的解决方案:stackoverflow.com/a/13919132/4608052