-1

I have seen code out there to use PHP to send an email to an SMTP server but it does not mean that the email went out properly.

I am wondering if you all have come across and end to end test of an SMTP server which would:

  1. Send a test email from SMTP to another server

  2. Retreive that email

    presumably there would be an ID in the email so that if this was done on a regular basis, the sent email could be connected to the received email.

Obviously this really would be testing the uptime of two servers and the inet connection between the two unless the SMTP server sent an email to itself.

Community
  • 1
  • 1
joel
  • 157
  • 1
  • 8
  • as long as the remote server supported imap, it would be trivial to write. –  Apr 12 '16 at 21:15
  • Not sure why I got a -1. It seems for PHP there are always a bunch of code examples. It seems like people would have code to make sure their SMTP server was up and running correctly. A good answer would help a number of users. – joel Apr 13 '16 at 16:31
  • Joel the problem is your asking for existing code, at S.O we help with code you have written. "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. " –  Apr 13 '16 at 20:46

1 Answers1

1

The way I do it is to configure an account on the remote SMTP server to autoreply to messages. Put a unique value in the subject line so you can identify the message that comes back (like a timestamp) and send off the message.

Use a script to POP the message from the mailbox on the local server the reply goes into and read the unique value (or use IMAP to read the message; either works as well).

If you use a timestamp then it's easy to measure how long it took for the roundtrip.

You'll want to have a mechanism to regenerate your ping message if it gets lost or fails to return in a reasonable time.

If you would prefer not to go the roundtrip route then send your message and use POP/IMAP to read it from the account you sent it to. That's even easier to do. -Rick

Rick Sanders
  • 541
  • 1
  • 3
  • 3