简体   繁体   English

已发送邮件检查它是否已交付并在Laravel中向收件人开放

[英]Sent Mail checking if it is delivered and open to recipient in Laravel

I want help in scaffolding code with Laravel default Mail package to send an email to the recipient with an enhancement that checks the status either mail is delivered to recipient and then check that either recipient opened the mail or not and then change the status of that email in my db_email_list . 我需要Laravel默认邮件程序包的脚手架代码帮助,以将电子邮件发送给收件人并具有增强功能,该功能可以检查状态,即邮件已发送给收件人,然后检查收件人是否打开了邮件,然后更改了该电子邮件的状态在我的db_email_list中 I googled it that to add headers just like follow the example but could not get it how to get the status 我用谷歌搜索它添加标题,就像遵循示例一样,但是无法获取如何获取状态

$message->getHeaders()->addTextHeader('X-Confirm-Reading-To','recipient_mail');

$sendEmail->getHeaders()->addTextHeader('Disposition-Notification-To','recipient_mail');

$sendEmail->getHeaders()->addTextHeader('Return-Receipt-To','recipient_mail');

When the user has gotten the email : Simply use this piece of code: 用户收到电子邮件后 :只需使用以下代码:

if (count(Mail::failures())) {
    return false;
} else {
    return true;
}

true=delivered , false=not delivered true=deliveredfalse=not delivered

When user reads the email: Hm sounds like you need to include a trick in your email in order to know if user has opened/read the email by simply adding for instance including an image on your email with a route defined in your end and passing user id as query param. 当用户阅读电子邮件时:嗯,听起来您需要在电子邮件中包含一个技巧,以便通过简单地在电子邮件中添加例如包含图像的示例(包括在您的末尾定义的路径)来了解用户是否已打开/阅读电子邮件用户ID作为查询参数。

<img src="http://www.example.com/user-read-email?user_id=20" />

So whenever the user opens the email img src will fire a call to your url and simmply get the user id from the url, and set the flag for that user in db. 因此,每当用户打开电子邮件时, img src都会触发对您的URL的调用,并从URL中简单地获取user id ,并在db中设置该用户的标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM