如何使用phpmailer跟踪smtp发送的邮件?

时间:2021-05-03 18:11:45

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

我正在正确地使用PHPMailer类向从数据库检索到的多个电子邮件地址发送电子邮件。

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.

我想将发送的邮件存储在DB表中。因为每个发送的电子邮件都可以通过点击电子邮件上的确认码来确认。我想记录下这一反应。

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.

通过链接的响应以唯一的确认代码发送到服务器。因此,如果确认邮件中的详细信息,表中的发送记录将使用bool/tinyint属性进行更新以记录。

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

我是否可以通过以下方式将邮件(通过smtp发送到phpmailer)存储在电子邮件账户中:用phpmailer发送的邮件不去“发送”IMAP文件夹?这样,邮件内容至少是可以访问的,因为我不想将这些细节存储在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

对于跟踪被退回的邮件,有一些解决方案:使用PHP跟踪SMTP发送的邮件

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....

我应该在哪里存储不发送的每封邮件的错误信息?应该将其记录在DB表中还是放在日志文件中?DB似乎更强大的搜索和查看....

2 个解决方案

#1


1  

1. You want to log the email outgoing and verify your users email by verification mail make following tables in your DB 如何使用phpmailer跟踪smtp发送的邮件?

1。您想要记录电子邮件发送,并通过验证邮件验证您的用户电子邮件在您的DB中的表。

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

    现在,在PHP中生成一个随机代码并将其存储在用户中——>verification_code

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

    在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.

希望这个有帮助。

#2


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.

如果你使用PHPMailer转达你的消息通过SMTP服务像http://www.ultrasmtp.com,http://sendgrid.com,和http://jangosmtp.com——任何这些服务将跟踪成功/失败的交付和开放的消息,并记录这些数据在自己的数据库,您可以查看报告或搜索,并把这个信息提供给你通过一个API或出口。

#1


1  

1. You want to log the email outgoing and verify your users email by verification mail make following tables in your DB 如何使用phpmailer跟踪smtp发送的邮件?

1。您想要记录电子邮件发送,并通过验证邮件验证您的用户电子邮件在您的DB中的表。

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

    现在,在PHP中生成一个随机代码并将其存储在用户中——>verification_code

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

    在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.

希望这个有帮助。

#2


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.

如果你使用PHPMailer转达你的消息通过SMTP服务像http://www.ultrasmtp.com,http://sendgrid.com,和http://jangosmtp.com——任何这些服务将跟踪成功/失败的交付和开放的消息,并记录这些数据在自己的数据库,您可以查看报告或搜索,并把这个信息提供给你通过一个API或出口。