PHPMailer and SMTP: Mail never shows up when sent

2019-07-28 05:47发布

问题:

I have a script that uses PHPMailer to send out an email. The email is sent with a direct SMTP connection to a remote mail server. The problem is that while everything seems to be okay when I run the script on my local machine, when the script is run on our live site using the same remote SMTP server the email never gets through. What's curious is that it seems to have worked at one point in time and has semi-recently decided that it just wasn't going to work anymore.

What potential points of failure are there? I do not have access to the SMTP server in question so I can't check its log files without submitting a support ticket, and although I was just given sudo access to the web server that is sending the email, I'm not quite sure what I'm looking for in terms of logfiles to go through, etc.

FWIW, my local machine is running Ubuntu 8.10, and the remote machine is running Red Hat Enterprise Linux ES release 4 (Nahant Update 1), so there is a bit of a difference in versions, but all I'm really looking for is a few pointers on where I should be looking for problems.

回答1:

How about you log into your live site, try to open a raw session to the remote SMTP server, and attempt to send email using raw SMTP commands? Doing so will help narrow down the possible causes of the problem.



回答2:

Is the remote machine behind a firewall? If it is, it might block the sending of e-mails. Or your SMTP server is disallowing access from the remote server.



回答3:

  • Is the machine behind a firewall?
  • Is the SMTP server configured to block certain hosts, or to only allow certain hosts?
  • Does the SMTP server require authentication for only certain networks?

You should look into debugging PHPMailer, it should be able to provide the raw SMTP requests and responses that you can look at to see if anything is going wrong.