无法使用PHP将邮件发送到个人电子邮件

时间:2016-03-15 10:42:30

标签: php phpmailer

需要解决方案:

我已经在PHP中编写了一个代码,我可以在phpmailer的帮助下发送电子邮件到gmail id,但是使用相同的代码我无法发送到个人域名的电子邮件是av@msdesigns.co.in。

当我发现这个问题时,所拍的电子邮件只被砍成a.v@msdesigns而不是a.v@msdesigns.co.in。

我试过的代码

<?php
require($_SERVER['DOCUMENT_ROOT'].'/PHPMailer/class.phpmailer.php');
require($_SERVER['DOCUMENT_ROOT'].'./PHPMailer/class.smtp.php');

$To = htmlentities($_POST['sendersName']);
echo $To;

$From = htmlentities($_POST['sendersEmail']);
echo $From;

$Subject = htmlentities($_POST['sendersMessage']);
echo $Subject;


$mail  = new PHPMailer();

$mail->Body ="Name :-" .$To. "\n <br>"."From :-" .$From. "\n <br>"."Subject :-"  .$Subject. "\n <br>";
$mail->IsSMTP();
$mail->SMTPAuth  = true;                 #enable SMTP authentication
$mail->SMTPSecure = "ssl";               #sets the prefix to the server
$mail->Host  = "smtp.gmail.com";         #sets GMAIL as the SMTP server
$mail->Port       = 465;                 #set the SMTP port
$mail->Username   = "a@gmail.com";                  #your gmail username
$mail->Password   = "yourpassword";                  #Your gmail password
$mail->From       = $From;             #your gmail id
$mail->FromName   = $To;                 #your name 
$mail->Subject    = "Message From".$To;


$mail->WordWrap   = 150;
$mail->AddAddress("a@gmail.com","abc");
$mail->AddAddress("a@gmail.com","abc");

$mail->AddAddress("a.v@msdesigns.co.in","Msd");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}

?>
  1. 请让我知道为什么只考虑a.v@msdesigns而不是 a.v@msdesigns.co.in
  2. 请告诉我如何将邮件发送到我的个人域名msdesigns.co.in

0 个答案:

没有答案