Email not working - Posted (1837 Views)
Starting Member
mark_laverty
Posts: 5
5
Hi!
First off, thank you for taking the time to read this. You help is much appreciated :-)

I have a snitz forum I have set up but I can't seem to get mail working. its at http://www.mltek.co.uk/forum.
Heres the contents of the inc_mail.asp file, I have removed everything that isn't 100% needed and I still can't get it to work..
<%
if trim(strFromName) = "" then
strFromName = strForumTitle
end if


Set iConf = Server.CreateObject ("CDO.Configuration")
Set Flds = iConf.Fields

'Set and update fields properties
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strMailServer
Flds("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Flds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxxx@mltek.co.uk"
Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxx"
Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "xxxxxxxx@mltek.co.uk"


Flds.Update

Set objNewMail = Server.CreateObject("CDO.Message")
Set objNewMail.Configuration = iConf

'Format and send message
Err.Clear

objNewMail.To = strRecipients
objNewMail.From = strSender
objNewMail.Subject = strSubject
objNewMail.TextBody = strMessage
On Error Resume Next
objNewMail.Send

If Err <> 0 Then
Err_Msg = Err_Msg & "<li>Your request was not sent due to the following error: " & Err.Description & "</li>"
End if


Set objNewMail = Nothing

on error goto 0
%>

If I run the testemailcomponent.asp page it shows that cdo is available (its the only one is shows as being avalable).
If I try to use the sendmail function when looking at a users profile it says that the message was sent, but the email never arrives.
If I try to register a new user then they dont recieve the confirmation email to the email address that they entered.
I am 99% sure that the SMTP details I have entered are correct. I can send and recieve email from this account using Outlook with the same settings.. any sugestions?
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Support Moderator
Podge
Posts: 3776
3776
Does your host have any code samples for sending email? Or any instructions at all?
Posted
Starting Member
mark_laverty
Posts: 5
5
Originally posted by Podge
Does your host have any code samples for sending email? Or any instructions at all?

Nothing that I have found.. BUT I do use .net in an aspx page to send mail from webforms on the root site..
Dim msg As New MailMessage
Dim emailClient As New SmtpClient("localhost", 25)
Dim SMTPUserInfo As New System.Net.NetworkCredential("xxxxxx@mltek.co.uk", "xxxxxxx")
Dim FromAddress As New System.Net.Mail.MailAddress("xxxxxx@mltek.co.uk")
msg.To.Add("xxxxxx@mltek.co.uk")
msg.From = FromAddress
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo

msg.Subject = "abc123"
msg.Body = "abc123"
emailClient.Send(msg)
Response.Redirect("confirm.aspx")
Posted
Support Moderator
Podge
Posts: 3776
3776
Try changing this
Code:

On Error Resume Next
objNewMail.Send

to this

Code:

On Error goto 0
objNewMail.Send

and then try to send an email. Post any error here.
Posted
Starting Member
mark_laverty
Posts: 5
5
Ok, script changed... I now get this..
"Send an E-MAIL Message

error '80040211'
/forum/inc_mail.asp, line 30
"

Heres the script exactly as it is on the server (with the exception of the 'xxxx's to not disclose sensitive information.

<%
if trim(strFromName) = "" then
strFromName = strForumTitle
end if
Set iConf = Server.CreateObject ("CDO.Configuration")
Set Flds = iConf.Fields

'Set and update fields properties
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strMailServer
Flds("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Flds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx@mltek.co.uk"
Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxx"
Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "xxxx@mltek.co.uk"
Flds.Update

Set objNewMail = Server.CreateObject("CDO.Message")
Set objNewMail.Configuration = iConf

'Format and send message
Err.Clear
objNewMail.To = strRecipients
objNewMail.From = strSender
objNewMail.Subject = strSubject
objNewMail.TextBody = strMessage
On Error goto 0
objNewMail.Send
If Err <> 0 Then
Err_Msg = Err_Msg & "<li>Your request was not sent due to the following error: " & Err.Description & "</li>"
End if
Set objNewMail = Nothing
on error goto 0
%>
Posted
Starting Member
mark_laverty
Posts: 5
5
Interestingly if I change use SSL to 'True' then I get this message...
CDO.Message.1 error '80040213'

The transport failed to connect to the server.

/forum/inc_mail.asp, line 30

If I set it back to False then I get the previous message again. I guess that means that at least it is trying to connect to the server and failing as opposed to not even trying.
Posted
Support Moderator
Podge
Posts: 3776
3776
Are you sure that strMailServer is set correctly? Try hardcoding it or entering the i.p. address.
Posted
Starting Member
mark_laverty
Posts: 5
5
Originally posted by Podge
Are you sure that strMailServer is set correctly? Try hardcoding it or entering the i.p. address.

Ok.. fixed it.. BUT I'm not 100% sure how.
I tweaked the script.. set the strmailserver to "localhost", deleted and re-created the mail account I am using and re-created it without a leading "_" in the password as the hosting providers site didnt seem to like that.
Here's the script as it is on the website now..
<%
if trim(strFromName) = "" then
strFromName = strForumTitle
end if
Set iConf = Server.CreateObject ("CDO.Configuration")
Set Flds = iConf.Fields

'Set and update fields properties
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strMailServer
Flds("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdobasic
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Flds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxx@mltek.co.uk"
Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxx"
Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "xxxxx@mltek.co.uk"
Flds.Update

Set objNewMail = Server.CreateObject("CDO.Message")
Set objNewMail.Configuration = iConf

'Format and send message
Err.Clear
objNewMail.To = strRecipients
objNewMail.From = strSender
objNewMail.Subject = strSubject
objNewMail.TextBody = strMessage
On Error goto 0
objNewMail.Send



If Err <> 0 Then
Err_Msg = Err_Msg & "<li>Your request was not sent due to the following error: " & Err.Description & "</li>"
End if
Set objNewMail = Nothing
on error goto 0
%>

So that seems to work great and I now have emails flowing even to external domains

Thank you very much for your help bigsmile
Posted
Support Moderator
Podge
Posts: 3776
3776
Glad you got it working.
 
You Must enter a message