0

My web app is done with php on a Linux server, we use swift-mailer library to deliver emails from the web app to our own mail server.

The thing is that I need to keep track of every email (sent or not sent) the web server processes, so in case the mail server goes down we can re-send the emails that haven't been sent when the mail server is up again. Our business model relies on sending emails to customers.

In brief, we need to store every email that hasn't been sent for any reason (generally because mail server is down).

I guess this can is done checking $failures parameter in SwiftMailer::send() if an email hasn't been sent, and storing it in a database table (mail_failures) or in a file inside a directory (mail/failures/).

My proposal is:

  1. insert any mail in a send queue
  2. remove mail from the queue when sent, or change its status to failure if not sent
  3. use a cronjob to invoke a php script that handles mail sending from the queue
  4. report is there's any email with failure status in the queue*

I would use rather database tables than system files

Is this the correct way of doing it? Any ideas or ways to improve it? Any software that handles this automatically?

Could it be handled via ZeroMQ?

Andrea
  • 11,801
  • 17
  • 65
  • 72
Packet Tracer
  • 3,884
  • 4
  • 26
  • 36
  • by the way i've read related posts to this issue http://stackoverflow.com/questions/3740624/how-can-i-keep-track-of-mail-sent-using-php-swift-mailer - http://stackoverflow.com/questions/7272742/swift-mailer-does-not-return-smtp-mail-failuer – Packet Tracer Feb 29 '12 at 17:45
  • and this http://stackoverflow.com/questions/5768389/swift-mailer-delivery-status – Packet Tracer Feb 29 '12 at 17:48
  • You can set up a mail server as high availability mail server instead of working around mail server faults within your webserver. Would that be an option? – Jörg Beyer Feb 29 '12 at 21:22
  • i guess that is achieved by setting up 2 mail servers, but don't know how it is done to make then work together. wouldn't it use too much resources from the server? mail server is a virtual machine on a physical one, that hosts more virtual machines (web server, mysql server, git repository) – Packet Tracer Feb 29 '12 at 22:27
  • could you give me some more info or where to start? what about the resources? is a good investment to have 2 mail servers when 99% of the time we'll be using only one? thanks – Packet Tracer Feb 29 '12 at 22:29
  • i'm not allowed to do with high availability on email server, i have to do it with php – Packet Tracer Mar 01 '12 at 09:13
  • the smarthost of your ISP typically is, or should be, HA. – Jörg Beyer Mar 01 '12 at 12:22
  • thanxs Jörg, we got our own server and the sysadmin has setup a postfix server, the problem is he is not intending to set postfix as HA. – Packet Tracer Mar 01 '12 at 14:59

0 Answers0