I'm using PHPMailer to send email via SMTP on a shared server (my hosting service is Softsys). Email is being sent fine to email addresses on the same server (i.e. the @ domain is my webdomain). However, when I try to change the recipient to @gmail (or any external address) I get the following error log:
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is开发者_StackOverflow中文版 "550 <jDoe@gmail.com> No such user here"
SMTP -> get_lines(): $data is "550 <jDoe@gmail.com> No such user here"
SMTP -> FROM SERVER:550 <jDoe@gmail.com> No such user here
SMTP -> ERROR: RCPT not accepted from server: 550 <jDoe@gmail.com> No such user here
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 OK"
SMTP -> get_lines(): $data is "250 OK"
SMTP -> FROM SERVER: 250 OK
Message could not be sent.
Mailer Error: SMTP Error: The following recipients failed: jDoe@gmail.com
Is this an issue with my server or my code? Should I just contact my server admin? Thank you in advance for any help!
Here's my code
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.mywebsite.com";
$mail->SMTPAuth = true;
$mail->Username = "myemail";
$mail->Password = "********";
$mail->From = "myemail@mywebsite.com";
$mail->FromName = "John Doe";
$mail->AddAddress("jDoe@gmail.com");
$mail->IsHTML(true);
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
Do you have shell access for your account? Then you might check some things like the MX record that you get with the command 'dig mx gmail.com'. If not, be best way is to contact you Hoster. I guess someone on the same server has configured the domain gmail.com. I guess they are using exim as MTA (because of the message response). It could be, that exim is trying to resolve to it's own host = local delivery because of a gmail.com domain on the server. Have you tried other Domains/Email-Addresses?
If you are trying to send email to gmail, gmail says that jDoe@gmail.com does not exist, try to use jdoe@gmail.com (remove caps). If not then try using some email you really know.
精彩评论