CDOSYS error '8004020e' sending to Yahoo - asp-classic

I am using CDOSYS for our asp classic mail.
OK, test mail with my yahoo account, and it sends out perfectly.
However, I use my clients email and password, and it gives an error '8004020e'.
I cannot figure out why it would be doing it. My client even had their password changed just to make sure that there was not a problem with the login information.
I will go back and use my yahoo email and password, and once again, it WORKS.
Just not with theirs.
Any idea's why it will work for one account but not for the other account?
Code below:
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =MailServer
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true 'Use SSL for the connection (True or False)
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = emailAdd
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = pass
myMail.Configuration.Fields.Update

That error is usually caused by one of the following
Incorrect SMTP server / port
Incorrect login/password
FROM address not valid according to SMTP server (wrong domain)
You've verified 1 & 2, so check #3

Related

CDO.Message To and From Fields Changed to "Friendly Name" and Email Address

When I first created this Classic ASP script, with the help of W3Schools, to send email, it worked fine. Now I'm having issues with sending the actual email; it appears to hang on the .Send method.
I noticed that when I set the To and From email address to just the email address, it reformats it to a "Friendly Name"/Email Address format:
myMail.From="Support#myDomain.com"
Response.Write myMail.From
The output of the Response Write is:
"Support#myDomain.com" <Support#myDomain.com>
I don't know if this was happening before, or if I should be setting the To and From fields in this format. Just to check if this is causing my problem, is there anyway to prevent these fields from being changed from just the email address?
Maybe the e-mail sending from the server now needs some kind of authentication such as setting these fields:
' Outgoing SMTP server.
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' Type of authentication, 0=NONE, 1-Basic (Base64 encoded), and 2=NTLM.
objCDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
' UserID on the SMTP server
objCDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "support#mydomain.com"
' Password on the SMTP server
objCDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "myemailpassword"
' Update config.
objCDO.Configuration.Fields.Update
The issue stemmed from the fact that the "From" email address was actually a distribution list and the account credentials used to login to the email server were not authorized to "Send As". Once that was rectified emails sent without further problems.
Thanks for the response.

windows 2008 server how to get ASPEmail to send to own domain

I have a friend who runs his website on a windows 2008 server. I have set up an asp classic form to email page on his website (hisdomain.com) which takes the input from a contact form and sends it out by email.
The problem is that it only works if the email is being sent to a different domain (something#anotherdomain.com). If the email is being sent to the same domain (anything#hisdomain.com) it never arrives.
Mailer.AddAddress "someone#anotherdomain.com"
Works.
Mailer.AddAddress "someone#hisdomain.com"
Does not work.
I have hunted this site and Google for a resolution but cannot find one.
Does anyone know how to fix this issue?
Many thanks
Tog Porter
Update: It turns out he uses Gmail business to control his domain emails and there was a filter in there that bounced the messages because the sender was the same as the recipient.
Bypassing the Gmail spam filter has fixed the problem.
Use this code and replace your smtp server information
<%
Set myMail=CreateObject("CDO.Message")
myMail.BodyPart.Charset = "UTF-8"
myMail.Subject= Your Message Subject
myMail.From= "anotheremail#anotherdomain.com"
myMail.To=Receiver Email Address
myMail.CreateMHTMLBody "Test Email Subject"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")= SMTP_SERVER
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")=SMTP_Email_Username
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")=Smtp_Email_Password
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>

Why emails are getting stuck in pick-up folder when sending through SMTP Service and CDO?

I'm programming Classic Asp with IIS8.5, so for sending email I use the SMTP Service (not the SMTP Server) with the CDO component. I want to send email using the pickup directory option:
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
So my code is:
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-relay.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxx#gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "The-pwd-123"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") ="C:\inetpub\correos\"
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "unicode-1-1-utf-8"
.To = "YYY <yyy#gmail.com>"
.From = "XXX <xxx#gmail.com>"
.Subject = "This is a subject"
.TextBody = "This is the body of the message"
.Send
End With
As you may know IIS8.5 come without SMTP Server, so there is no folder for the pickup directory (or I haven't found it yet), you must created, the problem I'm having is that the emails are getting stuck into the folder I created for that purpose.
https://support.google.com/a/answer/176600?hl=es
When you use the cdoSendUsingPickup option, you are simply writing the email message to a file which will be queued up for delivery asyncronously from your code. Yes, this is dramatically faster as your code does not have to wait for the SMTP server to receive the message. So, when using this option, you do not need to specify the destination SMTP server, the port, the username, password, etc.
Hopefully you are now asking yourself how does the server know where to send the message to if I don't specify a forwarding SMTP server. Well, that's because you just have to configure the Microsoft SMTP Service to let it know what server to hand off the messages to. There are plenty of articles online to configure it so you should not have any trouble finding that.

the server rejected one or more recipient addresses. the server response was 550 5.7.1 unable to relay

I am sending mails using our company SMTP server. I get the problem when I am sending mail to other mails (out side of the company domain), returning the error:
"The server rejected one or more recipient addresses. The server
response was 550 5.7.1 unable to relay".
If the mail is within the company, then there is no error and mail sending successfully. My web application hosted in IIS.
I'll assume that there is nothing wrong in your code. I guess it is a configuration issue i.e SMTP server configured to not send emails to addresses that are not part of your company domain. If so you need to check with your Windows/Network team to confirm configuration applied at SMTP server level.
I have Solved this problem. For using this code you need to add the namespace Using System.Web.Mail;
Source Code:
MailMessage mail = new MailMessage();
mail.To = "yourfromemail#domain.com";
mail.From = "yourtodomain#domain.com";
mail.Subject = "Email test.";
mail.Body = "Your body text here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send( mail );
//your need to add localhost address to IIS Manager.
Goto IIS Manager -> Default SMTP Server ->Properties -> Access -> Relay -> allow only from the list below -> add -> 127.0.0.1 -> Click OK

How can I send local Email by using exchange with asp.net?

I have a project that need to sends notification for employees by local email. I use SmtpClient class to send email but didn't work! here is the code:
MailMessage message = new MailMessage();
message.From = new MailAddress("localmail1#company.com");
message.To.Add(new MailAddress("localmail2#company.com"));
message.Subject = "Sending mail";
message.Body = "Check sending email by Exchange from asp.net code <> ";
SmtpClient client = new SmtpClient("ExchangeDNS", 25);
try
{
client.Send(message);
}
catch (Exception exc)
{
Label1.Text = exc.Message.ToString();
}
When I click buttons it give me an SmtpException with message : Failure sending mail.
NB: we use Exchange server.
How can I solve it?
Use the fully qualified name for your server, for example, exchangeDNS.example.com. If that doesn't work, try the IP address. You may want to manually telnet to port 25 on the Exchange server, just to see if it is possible. Also, check whether your server requires an authenticated or encrypted connection. If so, you'll need to supply credentials with the request or change to use SSL and the secure port.
Assuming that you have the server and any required credentials correct (double check these) I would try increasing the timeout on the SMTP client.
Your code is fine. It's the configuration of your Exchange server that is suspect. Some options for your Exchange administrator:
Allow anonymous SMTP connections.
Whitelist the IPs, so that only your web servers can send mail in this manner.
Create an Active Directory account for the web server, and then have your class authenticate using a username and password.
If you post more details about your Exchange configuration, I can help, at the risk of having this question downmodded for "not programming related".

Resources