Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    SMTP authentication values

    Hello

    I am getting a server message:

    error '80040211'

    /tell_Friends.asp, line 148
    This refers to the following: <b>ObjSendMail.Send</b>

    I have looked at some error diagnosis sites and quite a few of them suggest that the reason that the email form won't send is due to SMTP authentication. At the moment I have the following:

    Code:
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
         
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = myemail
    	ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mypassword
    Some sites out there indicate that I should change the 'cdo/configuration/sendusing") = 2' to 'cdo/configuration/sendusing") = 1'
    while others state that I need to change 'cdo/configuration/smtpauthenticate") = 1' to 'cdo/configuration/smtpauthenticate") = 2'

    I have tried these and neither works. Is it likely that the '/sendusing") = 2' and/or the '/smtpauthenticate") = 1' accounts for the form not sending, or am I barking up the wrong tree?

    The full code for this 'Tell a Friend' form is as follows:

    Code:
    <%@ LANGUAGE="VBSCRIPT" %>
    <% option explicit %>
    <% Response.Buffer = True %>
    
    <%
    'Declaring Variables
    Dim smtpserver,myemail,mypassword,friend_Name, friend_Email, friend_Subject,friend_Body,Action,IsError
    	
    ' Edit these 3 values accordingly
    
    smtpserver = "smtp.mySite.com"
    myemail = "info@mySite.com"
    mypassword = "myPassword"
    	
    ' Grabbing variables from the form post
    friend_Name = Request("friend_Name")
    friend_Email = Request("friend_Email")
    friend_Subject = Request("friend_Subject")
    friend_Body = Request("friend_Body")
    Action = Request("Action")
    
    
    ' Check correct email format
    Function IsValidEmail(Email)
    	
    Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserN  ame,DomainName,atChr,tAry1
    	ValidFlag = False
    		If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
    			atCount = 0
    			SpecialFlag = False
    			For atLoop = 1 To Len(Email)
    			atChr = Mid(Email, atLoop, 1)
    				If atChr = "@" Then atCount = atCount + 1
    				If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
    				If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
    				If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
    				If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
    			Next
    			If (atCount = 1) And (SpecialFlag = False) Then
    				BadFlag = False
    				tAry1 = Split(Email, "@")
    				UserName = tAry1(0)
    				DomainName = tAry1(1)
    			If (UserName = "") Or (DomainName = "") Then BadFlag = True
    			If Mid(DomainName, 1, 1) = "." then BadFlag = True
    			If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
    				ValidFlag = True
    			End If
    		End If
    		If BadFlag = True Then ValidFlag = False
    		IsValidEmail = ValidFlag
    End Function
    %>
    
    <html>
    
    <head>
    <title>Tell a friend</title>
    </head>
    
    <body style="font-family: Arial; font-size: 12px">
    
    <%
    If Action = "SendEmail" Then
    	
    	' Check/validate the information entered
    	
    	If IsValidEmail(friend_Email) = "False" Then
    		IsError = "Yes"
    		Response.Write("<font color=""red"">You did not enter a valid email address.</font><br>")
    	End If
    	
    	If friend_Name = "" Then
    		IsError = "Yes"
    		Response.Write("<font color=""red"">You did not enter a same.</font><br>")
    	End If
    	
    	If friend_Subject = "" Then
    	IsError = "Yes"
    		Response.Write("<font color=""red"">You did not enter a subject.</font><br>")
    	End If
    	
    	If friend_Body = "" Then
    		IsError = "Yes"
    		Response.Write("<font color=""red"">You did not enter any content.</font><br>")
    	End If
    	
    End If
    
    ' If there were no input errors and the action of the form is "SendEMail" we send the email off
    
    If Action = "SendEmail" And IsError <> "Yes" Then
    	
    	Dim strBody
    	
    	' Create html body for the email
    
    	strBody = strBody & "<font face=""Arial"">Tell a friend form submitted at " & Now() &  vbCrLf & "<br><br>"
    	strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") &  vbCrLf & "<br>"
    	strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "<br>"
    	strBody = strBody & "Name" & " : " & " " & Replace(friend_Name,vbCr,"<br>") & "<br>"
    	strBody = strBody & "Email" & " : " & " " & Replace(friend_Email,vbCr,"<br>") & "<br>"
    	strBody = strBody & "Subject" & " : " & " " & Replace(friend_Subject,vbCr,"<br>") & "<br>"
    	strBody = strBody & "<br>" & Replace(friend_Body,vbCr,"<br>") & "<br>"
    	strBody = strBody & "</font>"
    	
    	Dim ObjSendMail
    	Set ObjSendMail = CreateObject("CDO.Message") 
    
    'SMTP server configuration information
         
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
         
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = myemail
    	
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = myPassword
         
    ObjSendMail.Configuration.Fields.Update
         
    'End SMTP server configuration section
         
    ObjSendMail.To = friend_Email
            ObjSendMail.CC = myemail
    	ObjSendMail.Subject = friend_Subject
    	ObjSendMail.From = friend_Email
         
    ' Send html email
    
    	ObjSendMail.HTMLBody = strBody
    	'ObjSendMail.TextBody = strBody
         
    	ObjSendMail.Send
         
    	Set ObjSendMail = Nothing 
    
    %>
    <font size="2">Your message as seen below has been sent. Thank You !!
    <br><br>
    <font color="blue">
    <% =Replace(friend_Body,vbCr,"<br>") %>
    </font>
    </font>
    <% Else %>
    
    <form action="tell_Friends.asp" method="POST">
    <input type="hidden" name="Action" value="SendEmail">
    <font size="2">Tell a friend</font>
    <br><br>
    	<table border="0" cellspacing="1">
    		<tr>
    			<td valign="top">
    				Friend's name:
    			</td>
    			<td colspan="2">
    				<input type="text" name="friend_Name" size="35" value="<% =friend_Name %>">
    
    </td>
    </tr>
    
    <tr><td valign="top">Friend's email:</td>
    <td colspan="2"><input type="text" name="friend_Email" size="35" value="<% =friend_Email %>">
    			
    </td></tr>
    
    <tr><td valign="top">Subject:</td>
    
    <td colspan="2"><input type="text" name="friend_Subject" value="<% =friend_Subject %>" size="35">
    
    </td>
    </tr>
    
    <tr><td valign="top">Message:</td>
    
    <td valign="top">	<textarea rows="10" name="friend_Body" cols="40"><% =friend_Body %></textarea>
    
    </td>
    </tr>
    
    <tr><td valign="top">&nbsp;</td>
    
    <td colspan="2"><input type="submit" value="Send"></td>
    </tr>
    </table>
    </form>
    
    <% End If %>
    
    </body>
    
    </html>
    Thanks.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Not to ask a silly question, but... Are you sure that your site *requires* authentication? Many, if not most, ISPs don't require it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello Old Pedant

    Yes, the hosting service I use requires it.

    Maybe I should ask them whether it should be 1 or 2 (if they is the source of the problem)?

    Thanks for answering.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Yes, I think you'll have to ask them. The other common cause of that error--lines too long without line breaks--is clearly not your problem. Your lines are all nicely and correctly broken up.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    OK, thank you.

    I have contacted them - awaiting reply.

    Cheers


  •  

    Posting Permissions

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