asp email question

They have: 5 posts

Joined: Oct 1999

I am posting a 'message center' on a club website, using aspemail. I've got it working pretty well except for a couple of issues. Below is the most important one:

I have tested it with one purposely bad email address in the test database and want to receive a 'bounced' email back so I will know which address(es) are bad. Is there some code to do this? It's written in CDO which I have cobbled together with a little help from my friends since I'm not 'fluent' in object programming.

All help appreciated.

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

It's usually the job of the e-mail handling program to complain if there's a problem. Remember that the actual e-mail transmission is done completely away from your script.

You can stop malformed addresses (such as those with no '@' symbol, or no domain) but checking whether an e-mail address is actually valid is not easily done from within a script.

Is your e-mail send program not configured to complain if there's a problem? If you put an address in the from field it should return bounced mail there.

a Padded Cell our articles site!

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

My reading of the request was not of trying to handle badly formatted e-mails, but rather an e-mail that gets an automated responce from the server handing the domain name, ie. a mailbox no longer in use, one that is too full, etc.

I get a ton of messages each day from spammers that use faked e-mail addresses from my domains.

If this is the case, here is a rundown of what you need....

Your script sends out a mail something like this:

TO: [email protected] (the e-mail address your user entered)
FROM: [email protected] (the e-mail address you set up in your script)

the e-mail address is bad, no mailbox "johndoe" at the server for "maildomain.com", so you get an automated e-mail from the mail server, addressed TO: [email protected] that gives the details of the failed mail attempt.

You need your mail server set to send all e-mail to "formsender" to a script to process the e-mail. This would be up to your hosting company, or you would need to manually set up your own server to do so.

Once you do get it the incoming mail to a script, you wil have to handle them....

If this is the route you are wanting, let me know and I will post more details.

-Greg

They have: 5 posts

Joined: Oct 1999

Thanks for replying. Your first paragraph is right - but there will not be spams; this is an smallish club database of users and when club members change email addresses, they forget to send in a change, so the database is not updated.

Here's the thing: The mail form is for club members to use so the 'From' address is always different, i.e., not mine. The "To" address is the database of club members. Here's the relevant code:

<?php
   
' connect to the MS Access database in the same directory
    strDbPath = Server.MapPath(".") & "\users.mdb"
    ConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;;Data Source=" & strDbPath
    Const cdoSendUsingPickup = 1 '
Send message using the local SMTP service pickup directory.

    Const
cdoAnonymous = 0 'Do not authenticate
    Const cdoBasic = 1 '
basic (clear-text) authentication
   
Const cdoNTLM = 2 'NTLM

    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open "users", ConnectStr, 2, 3

    If Request("Send") <> "" Then
    Set objMessage = Server.CreateObject("CDO.Message")

        '
send email to all users
        objMessage
.Sender = ("[email protected]")
       
objMessage.From = Request("FromName")&"-Member Bay View Boat Club"
       
objMessage.Subject = Request("Subject")
       
objMessage.TextBody = Request("Body")

       
' read address from DB and put them in the BCC field
        While not rs.EOF


        objMessage.To = rs("Email")

   
            objMessage.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

            '
Name or IP of Remote SMTP Server
            objMessage
.Configuration.Fields.Item _
           
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.bayviewboatclub.org"

            'Type of authentication, NONE, Basic (Base64 encoded), NTLM
            objMessage.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic


            objMessage.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"

            '
Your password on the SMTP server
            objMessage
.Configuration.Fields.Item _
           
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "deleted here"

            'Server port (typically 25)
            objMessage.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

            '
Use SSL for the connection (False or True)
           
objMessage.Configuration.Fields.Item _
           
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

           
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
            objMessage.Configuration.Fields.Item _
            ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

            objMessage.Configuration.Fields.Update
            objMessage.Send
rs.movenext
        Wend

       

        Response.Write "Your message has been sent successfully"

    End If
?>

html form follows.

---
If either the sender or I get the bad emails that would be OK. Right now, no one gets them. (I have tested it using my own address as sender and a fake email address). Any further ideas?

Thanks,
Jessica

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

objMessage.Sender = ("[email protected]")'
This is the important bit. If there are problems with the to address or the message cannot be delivered, one of the e-mail servers should send a failure notice to this address.

What happens when you use a normal e-mail client (Thunderbird, Outlook, Outlook Express etc.) to send mail to a fake address using [incode]mail.bayviewboatclub.org[/incode] as your SMTP server?

If you don't get a failure notice back it's because that server isn't configured to send them. There's nothing your script can do to change that, it has to be setup correctly on the server.

My knowledge on this subject isn't comprehensive, but I'm reasonably sure that if you're not getting a failure notice sent to [incode][email protected][/incode] it's because of the way the mail server is setup (that being the one at: mail.bayviewboatclub.org)

Hope this makes sense. Smiling

a Padded Cell our articles site!

They have: 5 posts

Joined: Oct 1999

Thanks for all your help. It was a server issue and I've now gone over to Linux and php! Still awaiting my refund from the asp host I tried on a 'trial' basis...

J

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Jess wrote: Thanks for all your help.

Our pleasure! Smiling

Jess wrote: It was a server issue and I've now gone over to Linux and php!

Good choice.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.