CDO message wont send when delivery receipt requested

我是研究僧i 提交于 2020-01-15 05:37:25

问题


I'm writing an application in classic ASP (yes, please forgive me) that sends e-mails using Google Mail. I have it working just fine like this:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = SendUsername
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SendPassword
ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = "x@x.x"
ObjSendMail.From = "x@x.x"
ObjSendMail.Subject = "subject here..."
ObjSendMail.HTMLBody = "body here..."

'ObjSendMail.Fields("urn:schemas:mailheader:disposition-notification-to") = SendUsername
'ObjSendMail.Fields("urn:schemas:mailheader:return-receipt-to") = SendUsername
'ObjSendMail.Fields.Update
'ObjSendMail.DSNOptions = 14
ObjSendMail.Send
Set ObjSendMail = Nothing

When I uncomment out the following lines:

'ObjSendMail.Fields("urn:schemas:mailheader:disposition-notification-to") = SendUsername
'ObjSendMail.Fields("urn:schemas:mailheader:return-receipt-to") = SendUsername
'ObjSendMail.Fields.Update
'ObjSendMail.DSNOptions = 14

The e-mail fails to send. No error, just no e-mail and no delivery receipt. I can't figure out for the life of me how to make this work. "SendUsername" is a valid e-mail address. Any help would be appreciated.


回答1:


Its probably not working because Gmail doesn't want you doing this. This sort of thing is often explioted by spammers.




回答2:


I know it has been a few years since this was active, but I just found a solution so I am going to post it in case anyone else has this issue.

If you are using a 3rd party SMTP server, like gmail or even shared hosting and you do not have access to that servers configuration, there's really nothing you can do. The mail server will simply not relay any email with DSNOptions set. This is definitely to cut down on spam and abuse.

However, if you have access to WHM or are hosted with a company that will change settings for you (or you run your own SMTP server), you might be able set the host to which you will advertise DSN support. Now this setting may not be available on different mail server platforms, as I only currently have experience with Exim/WHM:

This will now allow you to receive successful delivery notifications and should also allow read receipts on successful emails. Notice that DSN options other than successful are no longer supported since any delayed or undeliverable email comes back to the sender anyways; it appears that only DSNOptions = 14 (All) or DSNOptions = 4 (Success) do anything at this point. Disclaimer: I don't know what ill effects this could have on spammers targeting your mail system, use at your own risk.

Also, another little trick is say you aren't interested in successful mails, you just want undeliverable mail to alert you at a different address than the sending address. Here you will get rid of DSNOptions and the disposition configuration, and simply just put the desired email address into objCDO.Sender like this:

objCDO.Sender = "returnedmail@domain.com"

Successful emails will still be from the preprogrammed address in your configuration (objCDO.From), however undeliverable emails will be returned to the objCDO.Sender address!

Hopefully this will help anyone who is still using Classic ASP with CDO mail and always wondered why they couldn't get this to work anymore.



来源:https://stackoverflow.com/questions/3791461/cdo-message-wont-send-when-delivery-receipt-requested

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!