phpmailer is working fine and able to use it in various ways, but.... I'm trying to find a way to determine if a valid looking email address actually made it to some destination. I am NOT talking about validating addresses such as...if (!$mail->validateAddress($email)) {echo 'Not a valid squiloople email pattern';}
This is my setup is using SMTP through gmail...
phpmailer工作正常,并能够以各种方式使用它,但....我正试图找到一种方法来确定一个有效的外观电子邮件地址是否实际上到达某个目的地。我不是在讨论验证地址,例如... if(!$ mail-> validateAddress($ email)){echo'不是有效的squiloople电子邮件模式';}这是我的设置是使用SMTP通过gmail ...
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = 0;
$mail->isHTML(true);
$mail->Host = 'smtp.gmail.com';
$mail->Username = "XXXl@gmail.com";
$mail->Password = "XXX";
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
If the email address looks like a duck and quacks like a duck then...$result = $mail->send();
Will Always return true!var_dump($mail->send()); // Also returns Boolean
Is there a way to test if the email was actually received somewhere? Or is this strictly a one-way shout-out through google's SMTP gmail servers???
Any tips, tricks, or pointers would be appreciated.
如果电子邮件地址看起来像鸭子,然后像鸭子一样嘎嘎叫...... $ result = $ mail-> send();永远都会回归真实!后续代码var_dump($ MAIL->发送()); //也返回布尔值是否有办法测试电子邮件是否实际收到了某个地方?或者这是通过谷歌的SMTP gmail服务器严格单向喊出???任何提示,技巧或指针将不胜感激。
6 个解决方案
#1
$mail->send()
will not always return true. It returns true if the part of the sending process it was involved with works. So if you send to an unknown address, but do so via gmail, gmail's servers don't know whether the address exists or not at the time, so it will be accepted and bounced later. If you were sending to a gmail address when sending through gmail, then it would fail immediately.
$ mail-> send()不会总是返回true。如果它所涉及的发送过程的部分有效,则返回true。因此,如果您发送到一个未知地址,但通过gmail发送,gmail的服务器当时不知道该地址是否存在,因此它将被接受并在以后退回。如果您在通过Gmail发送时发送到gmail地址,则会立即失败。
If an account does not exist at all, most servers (including gmail) will still give a 5.1.1 "Unknown user" response, and that will be reported correctly by PHPMailer if you send by SMTP directly to the recipient's supposed mail server (but not if you send via an intermediate server (like gmail) or using mail()
). PHPMailer doesn't have built-in support for doing that, but doing it yourself only involves a call to getmxrr
and setting Host
manually. Also you won't need to use authentication if you send that way.
如果帐户根本不存在,大多数服务器(包括gmail)仍将提供5.1.1“未知用户”响应,如果您通过SMTP直接发送给收件人的假定邮件服务器,则PHPMailer将正确报告该响应(但是不是你通过中间服务器(如gmail)或使用mail()发送的。 PHPMailer没有这样做的内置支持,但是自己动手只需要调用getmxrr并手动设置Host。如果您以这种方式发送,也不需要使用身份验证。
You can do various things like check if a domain exists at all - if it doesn't, mail delivery won't work. Some servers will accept all addresses and send bounces later (e.g. if they have a spam filter with a long processing queue), but if you get rejected up-front, it's a pretty sure indication that the address doesn't exist.
您可以执行各种操作,例如检查域是否存在 - 如果不存在,则邮件传递将不起作用。有些服务器会接受所有地址并稍后发送退回(例如,如果他们有一个带有长处理队列的垃圾邮件过滤器),但如果你被预先拒绝,那么这是一个非常确定的地址不存在的迹象。
You need to look into bounce handling too which will allow you to remove addresses that looked ok but later proved not to be, which is an entirely separate thing from anything that PHPMailer does. I will warn you now - bounce handling is extremely unpleasant!
您还需要查看退回处理,这将允许您删除看起来不错但后来证明不是的地址,这与PHPMailer所做的完全不同。我现在会警告你 - 弹跳处理是非常不愉快的!
You should also send using tls
on port 587, not ssl
on 465; see the gmail example provided with PHPMailer.
您还应该使用端口587上的tls发送,而不是使用465上的ssl发送;请参阅PHPMailer提供的gmail示例。
#2
You can ask for a receipt but the user has a choice and most people like me will not let it acknowledge receipt. All you can do is to make sure all your headers are correct and monitor the bounced emails.
您可以要求收据,但用户可以选择,像我这样的大多数人都不会让它确认收据。您所能做的就是确保所有标题都正确并监控退回的电子邮件。
#3
The only reliable way to confirm delivery is to get the recipient to answer. Tracking pixels don't work very well, or at all, and delivery receipts are often disallowed. Bounced emails only identify dead mailboxes that generate a non-delivery report - not all do - and won't identify a mailbox that's active but ignored. If the people you are emailing want something from you, don't give it to them until they've confirmed their address by responding to an email.
确认交付的唯一可靠方法是让收件人回答。跟踪像素不能很好地工作,或根本不工作,并且通常不允许交货收据。退回的电子邮件仅识别生成未送达报告的死邮箱 - 并非全部执行 - 并且不会识别活动但被忽略的邮箱。如果您发送电子邮件的人想要您的某些内容,请不要在他们通过回复电子邮件确认其地址之前将其提供给他们。
#4
Yes this can be done by - Using imap to read the bounced mail notification that gmail mailer-daemon sends back for undelivered mail and then parsing out the bogus address. Using that you can go back to your database and clean it up. My login/registration system will not require a valid email for basic access, but for elevated privileges it will. I'll just make an admin class function that processes privilege requests and also does database cleanup for basic accounts so there will be no lag-time for new user registration.
是的,这可以通过以下方式完成 - 使用imap读取gmail邮件程序守护程序发回的未发送邮件的退回邮件通知,然后解析出伪造的地址。使用它,您可以返回到数据库并进行清理。我的登录/注册系统不需要有效的电子邮件进行基本访问,但是对于提升的权限,它会。我将创建一个管理类函数来处理特权请求,并为基本帐户进行数据库清理,因此新用户注册没有延迟时间。
Thanks to all that had a look and contributed!!! Now that I'm about done I'll have a look at getmxrr
and see if that is better, but still plan to expand imap to automate email proxy account maintenance(deleteing, moving, ect...).
感谢所有有所了解和贡献!现在我已经完成了,我将看看getmxrr,看看它是否更好,但仍计划扩展imap以自动化电子邮件代理帐户维护(删除,移动等等)。
#5
The solution I found was :
1) To save a copy of the email in a mysql database with an ID.
2) Make sure the email is signed with the domain in 1024
3) Add a img to the email requesting an image from a PHP file like https://www.example.com/img.php?id=emailid with the email ID instead of emailid
4) In img.php get the email ID and update the corresponding entry of your database with the time and date and render a base64 image.
我发现的解决方案是:1)在带有ID的mysql数据库中保存电子邮件的副本。 2)确保电子邮件在1024中使用域签名3)在电子邮件中添加img,从https://www.example.com/img.php?id=emailid等PHP文件中请求图像,并附带电子邮件ID而不是emailid 4)在img.php中获取电子邮件ID并使用时间和日期更新数据库的相应条目并呈现base64图像。
So now you can know when the email is open and the time and date.
所以现在您可以知道电子邮件何时开放以及时间和日期。
#6
Try this:
if ( !PHPMailer::ValidateAddress($email) )
or
if ( !$mail->validateAddress($email) )
#1
$mail->send()
will not always return true. It returns true if the part of the sending process it was involved with works. So if you send to an unknown address, but do so via gmail, gmail's servers don't know whether the address exists or not at the time, so it will be accepted and bounced later. If you were sending to a gmail address when sending through gmail, then it would fail immediately.
$ mail-> send()不会总是返回true。如果它所涉及的发送过程的部分有效,则返回true。因此,如果您发送到一个未知地址,但通过gmail发送,gmail的服务器当时不知道该地址是否存在,因此它将被接受并在以后退回。如果您在通过Gmail发送时发送到gmail地址,则会立即失败。
If an account does not exist at all, most servers (including gmail) will still give a 5.1.1 "Unknown user" response, and that will be reported correctly by PHPMailer if you send by SMTP directly to the recipient's supposed mail server (but not if you send via an intermediate server (like gmail) or using mail()
). PHPMailer doesn't have built-in support for doing that, but doing it yourself only involves a call to getmxrr
and setting Host
manually. Also you won't need to use authentication if you send that way.
如果帐户根本不存在,大多数服务器(包括gmail)仍将提供5.1.1“未知用户”响应,如果您通过SMTP直接发送给收件人的假定邮件服务器,则PHPMailer将正确报告该响应(但是不是你通过中间服务器(如gmail)或使用mail()发送的。 PHPMailer没有这样做的内置支持,但是自己动手只需要调用getmxrr并手动设置Host。如果您以这种方式发送,也不需要使用身份验证。
You can do various things like check if a domain exists at all - if it doesn't, mail delivery won't work. Some servers will accept all addresses and send bounces later (e.g. if they have a spam filter with a long processing queue), but if you get rejected up-front, it's a pretty sure indication that the address doesn't exist.
您可以执行各种操作,例如检查域是否存在 - 如果不存在,则邮件传递将不起作用。有些服务器会接受所有地址并稍后发送退回(例如,如果他们有一个带有长处理队列的垃圾邮件过滤器),但如果你被预先拒绝,那么这是一个非常确定的地址不存在的迹象。
You need to look into bounce handling too which will allow you to remove addresses that looked ok but later proved not to be, which is an entirely separate thing from anything that PHPMailer does. I will warn you now - bounce handling is extremely unpleasant!
您还需要查看退回处理,这将允许您删除看起来不错但后来证明不是的地址,这与PHPMailer所做的完全不同。我现在会警告你 - 弹跳处理是非常不愉快的!
You should also send using tls
on port 587, not ssl
on 465; see the gmail example provided with PHPMailer.
您还应该使用端口587上的tls发送,而不是使用465上的ssl发送;请参阅PHPMailer提供的gmail示例。
#2
You can ask for a receipt but the user has a choice and most people like me will not let it acknowledge receipt. All you can do is to make sure all your headers are correct and monitor the bounced emails.
您可以要求收据,但用户可以选择,像我这样的大多数人都不会让它确认收据。您所能做的就是确保所有标题都正确并监控退回的电子邮件。
#3
The only reliable way to confirm delivery is to get the recipient to answer. Tracking pixels don't work very well, or at all, and delivery receipts are often disallowed. Bounced emails only identify dead mailboxes that generate a non-delivery report - not all do - and won't identify a mailbox that's active but ignored. If the people you are emailing want something from you, don't give it to them until they've confirmed their address by responding to an email.
确认交付的唯一可靠方法是让收件人回答。跟踪像素不能很好地工作,或根本不工作,并且通常不允许交货收据。退回的电子邮件仅识别生成未送达报告的死邮箱 - 并非全部执行 - 并且不会识别活动但被忽略的邮箱。如果您发送电子邮件的人想要您的某些内容,请不要在他们通过回复电子邮件确认其地址之前将其提供给他们。
#4
Yes this can be done by - Using imap to read the bounced mail notification that gmail mailer-daemon sends back for undelivered mail and then parsing out the bogus address. Using that you can go back to your database and clean it up. My login/registration system will not require a valid email for basic access, but for elevated privileges it will. I'll just make an admin class function that processes privilege requests and also does database cleanup for basic accounts so there will be no lag-time for new user registration.
是的,这可以通过以下方式完成 - 使用imap读取gmail邮件程序守护程序发回的未发送邮件的退回邮件通知,然后解析出伪造的地址。使用它,您可以返回到数据库并进行清理。我的登录/注册系统不需要有效的电子邮件进行基本访问,但是对于提升的权限,它会。我将创建一个管理类函数来处理特权请求,并为基本帐户进行数据库清理,因此新用户注册没有延迟时间。
Thanks to all that had a look and contributed!!! Now that I'm about done I'll have a look at getmxrr
and see if that is better, but still plan to expand imap to automate email proxy account maintenance(deleteing, moving, ect...).
感谢所有有所了解和贡献!现在我已经完成了,我将看看getmxrr,看看它是否更好,但仍计划扩展imap以自动化电子邮件代理帐户维护(删除,移动等等)。
#5
The solution I found was :
1) To save a copy of the email in a mysql database with an ID.
2) Make sure the email is signed with the domain in 1024
3) Add a img to the email requesting an image from a PHP file like https://www.example.com/img.php?id=emailid with the email ID instead of emailid
4) In img.php get the email ID and update the corresponding entry of your database with the time and date and render a base64 image.
我发现的解决方案是:1)在带有ID的mysql数据库中保存电子邮件的副本。 2)确保电子邮件在1024中使用域签名3)在电子邮件中添加img,从https://www.example.com/img.php?id=emailid等PHP文件中请求图像,并附带电子邮件ID而不是emailid 4)在img.php中获取电子邮件ID并使用时间和日期更新数据库的相应条目并呈现base64图像。
So now you can know when the email is open and the time and date.
所以现在您可以知道电子邮件何时开放以及时间和日期。
#6
Try this:
if ( !PHPMailer::ValidateAddress($email) )
or
if ( !$mail->validateAddress($email) )