我正在使用PHP Mailer发送电子邮件,我正在使用SMTP
这是我正在使用的代码:
$email = new PHPMailer();
$email->IsSMTP(); // telling the class to use SMTP
$email->Host = "mail.integradigital.co.uk"; // SMTP server
$email->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$email->SMTPAuth = true; // enable SMTP authentication
$email->Host = "mail.integradigital.co.uk"; // sets the SMTP server
$email->Port = 26; // set the SMTP port for the GMAIL server
$email->Username = "sending@************.co.uk"; // SMTP account username
$email->Password = "********"; // SMTP account password
$email->SetFrom($result["emailfrom"]);
$email->FromName($result["emailfrom"]);
$email->Subject = $result["subject"];
$email->Body = $result["message"];
Run Code Online (Sandbox Code Playgroud)
但它从Root用户发送和显示- root @ localhost
我知道我可以在class.phpmailer.php文件中更改此内容,但我希望能够在上面的代码中设置它
这可能吗?
Fan*_*ohn 12
好的,简而言之:
$email->From = "email.address@gmail.com";
$email->FromName = "Support Team";
Run Code Online (Sandbox Code Playgroud)
这对我有用.
把整个东西包裹起来.并在启用异常的情况下初始化phpmailer
$email = new PHPMailer(true);
Run Code Online (Sandbox Code Playgroud)
看起来使用了默认值.所以在打电话时出了问题setFrom().并且它无声地失败,因为它在false没有启用异常的情况下返回.
try {
// your mail code here
} catch (phpmailerException $e) {
echo $e->getMessage();
}
Run Code Online (Sandbox Code Playgroud)
并更改电子邮件的设置,并从名称更改为:
$email->setFrom($result["emailfrom"], $result["emailfrom"]);
Run Code Online (Sandbox Code Playgroud)
FromName 属性不是方法.
| 归档时间: |
|
| 查看次数: |
20419 次 |
| 最近记录: |