drzil26260 2016-12-30 05:55
浏览 42
已采纳

带有SMTP详细信息的PHPMailer

I would like to send mail from my php form. Initially I had used php mail function and it was working fine. But I recently shifted my server from windows to Linux in which SMTP is mandatory. I am not given access to php.ini file. Hence I am using phpMailer function. But when I use phpMailer, it gives me the following error

Invalid address: (punyEncode) abc-domain Mailer Error: Invalid address: (punyEncode) abc-domain.

My username is not my mail address i.e., abc@domain.com but it is abc-domain. Here is my code. I have PHPMailer files in a folder called PHPMailer.

<?php
require('PHPMailer/PHPMailerAutoload.php');

$mail = new PHPMailer;

$mail->CharSet = "UTF-8"; 


$mail->SMTPDebug = 3;                               

$mail->isSMTP();            

$mail->Host = "mail.abc.com";

$mail->SMTPAuth = true;                          

$mail->Username = "abc-domain";                 
$mail->Password = "abc123";                           

$mail->Port = 25;                                   

$mail->From = "abc-domain";
$mail->FromName = "Webmaster-Domain";

$mail->addAddress("xyz@domain.com", "xyz");

$mail->isHTML(true);

$mail->Subject = "Subject Text";


$mail->Body = '<h1 style="font-family: Arial;">HTML Text</h1>';

if(!$mail->send()) 
{
    $mail->SMTPDebug = true;
    echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
    echo $success;
}
?>

Is there a way to setup SMTP details through .htaccess?

  • 写回答

1条回答 默认 最新

  • duanjiuhong5843 2016-12-30 06:06
    关注

    The problem is here

    $mail->From = "abc-domain";

    It should be a valid email, even if you user isn't (which is ok, because you only need it here $mail->Username)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端