SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: problem using cdo .form field
-
Nov 30, 2010, 16:52 #1
- 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.
-
Dec 1, 2010, 00:34 #2
- 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
-
Dec 1, 2010, 05:26 #3
- 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!
-
Dec 1, 2010, 06:38 #4
- 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!!
-
Dec 1, 2010, 09:04 #5
- 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.
Bookmarks