SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem using cdo .form field

    Hi,

    I am developing a site using classic asp vbscript.
    I have created a form submission page that allows users to submit requests for work to the web sites members. Amongst the posted form fields is a textbox that requests an email address so that members can contact the requester. Once posted back, the vbscript loops through a database and pulls out members email address and then sends the posted information to the members email address's using CDO.Configuration & CDO.Message.
    The problem I have is that I use an email account registered with the hosting account to send the form information to the members. Unfortunately, despite explicitly stating that the email has been generated form the hosting site, some of the members click on their reply buttons thinking that they are directly replying to the person submitting the form request.
    I have tried setting the .From field of the CDO.Message to the requestors email but when testing, if I use my gmail email address, I get a DNS error message - Status: 5.7.1
    Diagnostic-Code: smtp;554 5.7.1
    I'm aware that the problem here is that my email address is being forged.
    How can I get this request form to work, to successfully send out the request to the site's members using the requester's email address as a from field?
    Am I incorrectly using an email account that is registered with the sites domain? It's my understanding that to use the sites email server, i have to set field items such as .Item(cdoSMTPServer), .Item(cdoSendUserName), and .Item(cdoSendPassword), to use a email account that has been registered via the site?
    Any help is greatly appreciated.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    It's hard to say without seeing the code that is in question however, you should be able to do this because CDO is just relaying the email message from one email address to another using the SMTP server on your hosting account.

    It should be achieved by putting the from address in the variable responsible for the from address:

    Code:
    Dim ObjMail
        Set ObjMail = Server.CreateObject("CDO.Message")
        objMail.From = "the-from-email@address"
        objMail.To = "recipient@address" 
        objMail.Bcc = "" ' BLIND CC EMAIL ADDRESS
        objMail.Subject = "THE SUBJECT"
        objMail.HTMLBody  = "EMAIL BODY" 
        objMail.Send
    
        Set objMail = Nothing
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  3. #3
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply - I've posted a condensed version, with the relevant lines of code, below -

    Code ASP:
    const cdoSendUsingMethod        = _
    "http://schemas.microsoft.com/cdo/configuration/sendusing"
    Const cdoSendUsingPort          = 1
    Const cdoSMTPServer             = _
    	"http://schemas.microsoft.com/cdo/configuration/smtpserver"
    Const cdoSMTPServerPort         = _
    	"http://schemas.microsoft.com/cdo/configuration/smtpserverport"
     
    Dim objConfig  ' As CDO.Configuration
    Dim objMessage ' As CDO.Message
    Dim Fields     ' As ADODB.Fields
     
    Set objConfig = Server.CreateObject("CDO.Configuration")
    Set Fields = objConfig.Fields
    With Fields
    	.Item(cdoSendUsingMethod)       = cdoSendUsingPort	
    	.Item(cdoSMTPServer)            = "localhost"	
    	.Item(cdoSMTPServerPort)        = 25
    	.Update
    End With
     
    Set objMessage = Server.CreateObject("CDO.Message")
    Set objMessage.Configuration = objConfig
    Set rs = Server.CreateObject("ADODB.Recordset")
    sql = "SELECT email FROM company3"
    rs.open sql, conn
    While Not rs.EOF
    recipient = rs("email")
    	With objMessage
    		.To       = recipient
    		.From     = "my.email@gmail.com"
    		.Subject  = "SMTP Relay Test"
    		.TextBody = "SMTP Relay Test Sent - " & Now()
    		.Send
    	End With
    rs.MoveNext
    WEND
     
    Set Fields = Nothing
    Set objMessage = Nothing
    Set objConfig = Nothing
    rs.close
    set rs = nothing
    conn.close
    set conn = nothing

    So, in the summurised version of my code, i've used my gmail address, instead of the a form textbox field value(in my app's code I've tested submitting the form and used my gmail address, and unfortunatly I get the DSN error - Action: failed
    Status: 5.7.1
    Diagnostic-Code: smtp;554 5.7.1
    in my gmail spam box.
    Please any more help is appreciated!

  4. #4
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In my vbscript I have just added .ReplyTo ="my@email@gmail.com" and its worked!!

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Cool. Glad you got it sorted.

    One piece of advice ... unless each email needs some unique info in it, you might be better creating only one email and then looping through your recordset to build a list of .Bcc recipients.

    So .To would be yourself, .From the same. ReplyTo also the same, and then .Bcc the list of intended recipients. This might help prevent your emails being seen as SPAM by the SMTP server, by triggering a rate limit.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •