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?
Edited by - mark_laverty on 03 October 2011 07:04:47
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
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 %>
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.
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
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
Edited by - mark_laverty on 03 October 2011 10:02:26