locked
CDOSYS mail failing error '8004020e' when sending to exernal addresses RRS feed

  • Question

  • User1861004525 posted

    windows server 2008 / IIS 7

    so i've been using CDOSYS mymail functions for a while along with our office365 managed external mail provider.
    it works and can send to any email address as long its within the same "email domain"..

    however i have since found out that it fails when trying to send to any external email address, with the usual #error '8004020e' error.

    what i can't understand is why it fails here, but when we use the exact same account/authentication details on a different system that auomates reports for us (jeffnet), then it is able to send to external address just fine.
    so i can only assume it is either an IIS config issue or a code issue.

    the code i am using is

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Mail Test"
    myMail.To="default@example.com"
    myMail.TextBody="Test"
    
    myMail.From="blah@myoffice365email.com"
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "blah@myoffice365email.com"
    myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password123"
    
    myMail.Configuration.Fields.Update
    myMail.Send
    set myMail=nothing
    %>

    jeffnet uses just the following details

    SMTP server : smtp.office365.com
    SMTP port : 587
    mail account name : blah@myoffice365email.com
    authentication id : blah@myoffice365email.com
    authentication password : password123

    so can anyone help with what the issue might be?
    i can only assume it's not an office365 issue, otherwise jeffnet would also fail to send to external addresses.

    Tuesday, February 26, 2019 2:38 PM

All replies

  • User-848649084 posted

    Hi Chenks,

    This error is caused by the email components not being able to send email.

    The causes of this error are:

    • Incorrect SMTP server / port.
    • Incorrect login/password. You must supply a correct and valid value in your email.asp file.
    • Access to the mail server through the email component is denied. Make sure you are using a valid SMTP Server in your email.asp file.
    • The email address used in the FROM field doesn't contain a valid email address. Verify that you're validating the FROM field value against a valid email address present on the SMTP Server.
    • Some mail servers do not allow sending emails using a From email address with a domain name different than the one is configured in the web server. In this case, you should not use a field of the HTML form as the From. Instead, use a Generic email address with the same domain name as the hosted one.

    Regards,

    Jalpa.

    Wednesday, February 27, 2019 7:44 AM
  • User1861004525 posted

    Thanks Jalps, but did you read what i posted?
    the email componenta ARE able to send email, as long as they are internal email addresses, it only fails when sending to external.

    1)the SMTP server/post is correct, as shown when using another application with the exact same details

    2)login/password is correct, as shown when using another application with the exact same details

    3)access to the mail server is fine, again it can send emails providing it is "internal" emails

    4) the FROM field is valid

    5) i don't follow what you're saying in this part. the email is external hosted by office365, the webserver is internal on our own network. as i said though it can send emails providing they are internal, it can only not send to external addresses.

    Wednesday, February 27, 2019 7:53 AM
  • User1861004525 posted

    UPDATE - i've done some further testing and it appears that it must be a server config issue.

    if i have the exact same code on an old Windows 2003 Server (on the same network) then it works fine for both internal and external emails.

    so this shows that the ASP code and the SMTP server/login details are all correct.

    it only fails when running on the Windows 2008 server.

    so what might be the issue?

    Wednesday, February 27, 2019 8:14 AM
  • User1861004525 posted

    anyone?

    Friday, March 1, 2019 11:34 AM
  • User-848649084 posted

    Did you follow same steps to configure  server? could please describe the steps which you followed?

    Tuesday, March 5, 2019 7:17 AM
  • User1861004525 posted

    they are different servers, so following steps wouldn't be appropriate

    the original server is windows server 2003, the server now being used is window server 2008.

    the setup processes are different.

    however both are running IIS and both are operating correctly as web servers.

    the server 2008 can clearly communicate with the external office365 mail server (otherwise it wouldn't be able to send emails to any addresses on @myoffice365email.com, it only fails when trying to send to any other email, eg @gmail.com)

    Tuesday, March 5, 2019 7:43 AM