1

I'm using PHPMailer class correctly to send emails to multiple email addresses retrieved from the database.

But should I store the emails sent and not sent with their reason in a database table?

I would like to store sent emails in a DB table. Because every sent email can be confirmed by clicking the link on the email with a confirmation code. This response I would like to record.

The response via the link is sent to the server with a unique confirmation code . So the sent record in the table will be updated with a bool/tinyint attribute to record if details in email are confirmed.

Could I allow the emails (sent via smtp with phpmailer) to be stored in sent folder within email account by following this: Sent mails with phpmailer don't go to "Sent" IMAP folder ? That way the email content is atleast accessible as I don't want to store those details in DB

Is it better to record sent email sent in database?

For tracking bounced emails there are solutions: Track emails sent by SMTP with PHP

But what about the event where email is not sent due to an error? Example when this happens:

if(!$mail->Send())
{
   echo "Mailer Error: " . $mail->ErrorInfo;
}

Where should I store the error info for each email not sent? Should this be recorded in DB table or put in log file? DB seems more powerful for search and viewing....

Community
  • 1
  • 1
Qwerty
  • 293
  • 6
  • 30

2 Answers2

1

If you use PHPMailer to relay your messages through an SMTP service like http://www.ultrasmtp.com, http://sendgrid.com, or http://jangosmtp.com - any these services will track successful/failed deliveries and opening of messages, and record this data in their own database from which you can view reports or search, and also make this info available to you through an API or export.

mti2935
  • 9,797
  • 3
  • 23
  • 28
  • Ah ok yes I was thinking of using these. But are they ok to use for non-marketing emails (specifically can be used quotation request/details emails?). In that case I'm considering Mandrill (http://mandrill.com/) to start with since first 12k emails/month are free – Qwerty Mar 06 '15 at 21:00
  • Is Mandrill ok to use for this? – Qwerty Mar 06 '15 at 21:01
  • Also I would like to use own domain SMTP credentials instead of the email cloud service's one - is that possible? – Qwerty Mar 06 '15 at 21:01
  • Does this work? http://help.mandrill.com/entries/21681347-How-do-I-set-up-sending-domains- – Qwerty Mar 06 '15 at 21:04
1

1. You want to log the email outgoing and verify your users email by verification mail make following tables in your DB enter image description here

  1. Now generate a random code in PHP and store it in users->verification_code

  2. Send the same code into your user while inserting the email details in email_log.

  3. When the users click's your verification link in his inbox cross check it with the one stored against his data in users table if its correct give him the access by changing verified to true.

Hope this helps.

Shubham
  • 82
  • 1
  • 13