2

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.

Sparafusile
  • 4,696
  • 7
  • 34
  • 57

2 Answers2

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:

Screenshot of this in Exim configuration manager

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.

1

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

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
  • I get a delivery failure notice, but not a delivery success notice. I'm not sure how one can lead to an exploit, but not the other. – Sparafusile Sep 28 '10 at 16:56
  • 1
    @Sparafusile: Its not uncommon for destination SMTP server to ignore delivery success notification request. If you look at the spec DSN is only requesting this feature the SMTP servers are not obliged to honor it. In the real world imagine the extra load all that potential messaging would represent. – AnthonyWJones Sep 28 '10 at 17:08
  • Ok, so the SMTP decides not to send a delivery receipt, fine. Why isn't the code above even sending the e-mail in the first place? Is there an error in the code that's preventing it from working even though I wouldn't ever get the desired result? – Sparafusile Sep 29 '10 at 11:32