1

I'm developing a little email sender portal that allows registered users to send some amounts of emails. I use a secure connection with an SMTP server installed on localhost (I mean same server of Apache and PHP) to send the emails and I have implemented a system to take control on the amounts of emails sent (I schedule the sending of the emails to avoid sending too much emails at the same time).

I use PHPMAiler class to send the emails and a class of my own to schedule them.

The only thing I miss is to track the emails I've sent to know if some errors occured (and which error in particular ie. address not found, recipient mailbox full, etc...) and to know if the user opened the email and when.

I admit that I actually know almost nothing about SMTP servers, but I'd like to know if there are some resources where I can find a PHP class that can talk to the SMTP server to ask it for the sent emails, or if there's any way in PHP to retreive sent emails information.... or anything else that could be useful for my purposes.

2
  • 1
    The server will usually issue a bounce back email for errors and for open rate tracking just include an image in the body of the email and detect whether it has been downloaded.
    – Treffynnon
    Nov 15, 2011 at 8:48
  • Do you mean the email I can specify in "Reply-to" header? Nov 17, 2011 at 10:25

2 Answers 2

3

Unfortunately there is no way to 'track' email once the SMTP server has send it to the recipients mailserver.

If the receiving email server encounters an error it will automatically send the error message to the sender address. This will probably be the e-mail adres of the registered user who tries the send the email.

Hope this helps.

1
  • Thank you very much for your answer! I didn't think about adding an image to the message, even a 1x1px blank image, rendered by my php script, from which I can take any information I want! Thanks for the suggestion! Nov 17, 2011 at 10:17
1

There is no way to track the email once it leaves however you do have two options. One is to check for bounced messages. Normally outgoing messages will specify a return-path that the bounces will go to.

The other option is that you do have control of the sending server. If the server that you are sending to is the server that complains that the user is missing for example then you will receive one of the SMTP error codes. SMTP error codes are pretty much the oposite to HTTP ones in that 500's are hard bounces (permanent errors like user is not known here) and 400's soft bounces (temporary errors).

Finally it is also possible to add a small image (that will render via your php script) to track opens of an email, obviously this won't help if the user blocks the images but it can provide some idea that the user has read the emails (along with link tracking)

4
  • Thank you so much! I'll try with the image to keep a track of the opened emails, for sure! Nov 17, 2011 at 10:18
  • I just don't understand how and where I can receive the the error response from the SMTP server. I mean, I send an email from my SMTP server (which I can have control of). Then, who is giving me a bounce message? And how can I read it, and where? How can I specify the return path to the SMTP server to have a response back (confirm or error message)? Thank you very much for your help! Nov 17, 2011 at 10:24
  • The return path is an email address that is passed as a header within the original message sent. You add return-path: [email protected] to the message headers and all bounces should be sent to that address. en.wikipedia.org/wiki/Return_path. Also upvoted @Treffynnon's comment as it does actually hint at most of this solution. Nov 17, 2011 at 20:03
  • Thank to you all!! Now I can proceed with my project! Thank you!! Nov 18, 2011 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.