Problems with Email Forms

sonata

Perch
I'm getting a bit frustrated with this as I go around on it again. The last time I puttered with it for almost 12 hours before it inexplicably started working. Adding insult to injury, I'm using the script that I got working before!

I have a simple contact form that is supposed to send an email to the client's email address and a copy to the visitor. The client's email is hosted on JH servers and goes through immediately. However, the CC goes to another email server and is not being sent. I assume the problem is with authentication.


The code I am using is based on code that has been posted on these boards. My version follows:

**********

Dim objMessage
Dim objSettings
Dim iFlds

Set objMessage = Server.CreateObject("CDO.Message")
Set objSettings = Server.CreateObject("CDO.Configuration")
Set iFlds = objSettings.Fields

iFlds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.net"
iFlds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'SMTP port
iFlds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 'CDO Port
iFlds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 'timeout
'outgoing authentication
iFlds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
iFlds("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
iFlds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
iFlds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"

iFlds.Update

Set objMessage.Configuration = objSettings

With objMessage
.From = Request.Form("txtSenderName") & " <" & Request.Form("txtFromAddress") & ">"
.To = "[email protected]"
.Cc = Request.Form("txtSenderName") & "<" & Request.Form("txtFromAddress") & ">"
.Subject = Request.Form("txtEmailSubject") & " (sent via contact form)"
.TextBody = Request.Form("txtEmailBody")
.HTMLBody = "<p>" & Replace(Request.Form("txtEmailBody"), vbCrLf & vbCrLf, "</p><p>") & "</p>"
.Send
End With

Set objMessage = Nothing

***************

I have verified that all email addresses, mail server addresses, and passwords are correct. My reseller account has a TLD of .net and my business email address is .com., so if anyone was going to mention that, it is correct. I don't know what else to check at this point. Any help will be greatly appreciated.
 
the domain that is being CCed, is it on the server here as well?

If would be helpful if you could send me the domain that is not hosted here(dont care about full address), and I will check that for you.
 
Do you have to use CDO?

I'd rather use AspEmail... here's an example:

Code:
<%
' change to address of your own SMTP server
strHost = "mail.elinkisp.com"
If Request("Send") <> "" Then
   Set Mail = Server.CreateObject("Persits.MailSender")
   ' enter valid SMTP host
   Mail.Host = strHost

   Mail.From = Request("From") ' From address
   Mail.FromName = Request("FromName") ' optional
   Mail.AddAddress Request("To")

   ' message subject
   Mail.Subject = Request("Subject")
   ' message body
   Mail.Body = Request("Body")
   strErr = ""
   bSuccess = False
   On Error Resume Next ' catch errors
   Mail.Send ' send message
   If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
   End If
End If
%>

<HTML>
<BODY BGCOLOR="#FFFFFF">
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
<FORM METHOD="POST" ACTION="Simple.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<TR>
   <TD>Host (change as necessary in script):</TD>
   <TD><B><% = strHost %></B></TD>
</TR>
<TR>
   <TD>From (enter sender's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="From"></TD>
</TR>
<TR>
   <TD>FromName (optional, enter sender's name):</TD>
   <TD><INPUT TYPE="TEXT" NAME="FromName"></TD>
</TR>
<TR>
   <TD>To: (enter one recipient's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="To"></TD>
</TR>
<TR>
   <TD>Subject:</TD>
   <TD><INPUT TYPE="TEXT" NAME="Subject"></TD>
</TR>
<TR>
   <TD>Body:</TD>
   <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
   <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
 
KC,

ASPemail is only the free, not premium version, so it does not work with smtp auth.
 
I found that by changing the CDO Port option from "1" to "2" that the emails started going out to the external server (which is the CC address). Why the script works on the original site and not on this one I don't know. Both sites are on JH servers.

I will be using this script on another site in the next few days, so I'll see how it works on that one. In the meantime, things seem to be working now.
 
Back
Top