Cannot send emails to yahoo using mailkit - yahoo

I am creating a system that sends emails (pricing, orders, invoices, etc) to out customers. But due to the number of emails that ends up being, we hit limits when trying to send through gmail or any other mail client. And since these are all customer specific emails using a bulk sending client is not ideal.
So I have created a system using mailkit and others to send our emails from our own servers without needing to set up a relay or email server for sending. This works great with everyone (Gmail, outlook, etc) except for yahoo. For some reason when I connect and mailkit tries to switch to STL (via startstl) yahoo sends garbage and mail kit fails.
I have enabled all ssl and tsl protocols. And I have ServerCertificateValidationCallback always to return true. In fact ServerCertificateValidationCallback doesn't even get called.
The errors that are thrown start with:
A call to SSPI failed, see inner exception
then
The message received was unexpected or badly formatted.
If I try to connect to any of the other SMTP ports 465 or 587 the system just hangs.
This all happens when connecting, before the email is sent. So it cannot be a DKIM issue. And the SPF record is set up correctly. We don't have the reverse dns setup because we plan on sending from multiple servers with different IPs.
I don't know why yahoo is being so difficult.
Tried talking with MailKit, tries allowing all TLS and SSL connections. Tried finding any YAHOO support.
using (var client = new SmtpClient())
{
client.LocalDomain = "MyDomain";
// right now we don't care about all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = (s, c, h, e) => {
return true;
};
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls11 |
System.Security.Authentication.SslProtocols.Tls12 |
System.Security.Authentication.SslProtocols.Tls |
System.Security.Authentication.SslProtocols.Ssl3 |
System.Security.Authentication.SslProtocols.Ssl2;
client.CheckCertificateRevocation = false;
client.Connect("mta6.am0.yahoodns.net", 25, false); //<--- fails here
client.Send("test", fromMailBoxAddress, recipientsEmailBoxAddresses);
client.Disconnect(true);
}

To answer your question, I might have an idea why Yahoo is being so difficult - it's possibly your message construction. Verify your MimeMessage has the same exact email address for your From and Sender addresses. Ensure your ReplyTo only contains the Sender email address. I had both the sender and recipient email addresses in the ReplyTo and Yahoo did NOT like that. And, of course, you are using a Yahoo App password for authentication. Once I made these two changes, Yahoo sent the email successfully.
Settings
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
client.DeliveryStatusNotificationType = mail.DeliveryStatusNotificationType.Full;
await client.ConnectAsync("smtp.mail.yahoo.com", 587, SecureSocketOptions.StartTls);
await client.AuthenticateAsync(yourEmailAddress#yahoo.com, yourYahooAppPassword);
await client.SendAsync(Message);
await client.DisconnectAsync(true);
Research
Bad message construction breaks one of Yahoo's many policies. This was ONLY happening with SMTP via Yahoo. SMTP via Gmail and Outlook work fine. I kept comparing a simple MailMessage with MimeMessage message construction. MailMessage sent, MimeMessage failed, I kept getting a 550 request failed; mailbox unavailable response from Yahoo every time with my MimeMessage. I verified by using ProtocolLogger. My From was empty and that is one issue, and, I had the recipient in my ReplyTo. If I merely added the sender to the ReplyTo, it still throws that same 550 error. I had to ensure the sender was the only email in the ReplyTo.
Hope this helps.

Use client.Connect("mta6.am0.yahoodns.net", 25, SecureSocketOptions.None); if you want to disable STARTTLS or use client.Connect("smtp.mail.yahoo.com", 587, SecureSocketOptions.Auto); which works fine.
Not sure where you are getting "mta6.am0.yahoodns.net" from, but I can't even make a normal socket connection to that address.

Related

How do I retrieve the sender number when using Twilio's messaging services with Copilot enabled?

I have a Twilio messaging service with Copilot and the sticky sender feature enabled.
I would like to view the phone number that Copilot assigns to my recipients when I send them a message.
With the Ruby client, I get a MessageContext object when I send a message, but it only has the
messaging service SID - the from method returns nil.
Currently, this is how I'm sending messages:
def send(from, to, message)
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
client.api.account.messages.create(
body: message,
messaging_service_sid: from,
to: to,
status_callback: BASE_URL + '/sms_status/status',
)
end
Twilio developer evangelist here.
I'm not sure, but you might not have the phone number at the time you make the API request using a messaging service. This request really just queues up the message to be sent.
I would check the message object once it has been sent. You have a status callback URL setup, so you should be able to either inspect the parameters sent to that URL or look up the message from the API using its SID and then get the number that was used.

Mandrill for outgoing mail in a mail client

I'm using Mandrill for my transaction email needs and it works great. Unfortunately very often when I send emails via my email client the emails go to the recipients spam folder.
Is there a way to use Mandrill for outgoing emails via a mail client (such as Apple Mail or Thunderbird)?
You can use the Mandrill's Outgoing Server (SMTP) Setting in the MailClient of your choice.
SMTP Settings
Outgoing Server: smtp.mandrillapp.com
Outgoing Server Port: 587
Auth Required: True
TLS: True
Username: complete email-id
Changing the MailClient is not probably going to mark your mails as legitimate.
There are multiple reasons for mail going to spam folder of recipient like:
Mandrill's IP address got blacklisted in recipient's SMTP (MX) server.
Your mail contains some links or content which is recognized as suspicious and hence recipient marks such mails as spam.
In short, mail getting marked as spam depends upon:
Sender SMTP server's reputation.
Sender's mail content.
Receiving SMTP (MX) (i.e recipient's) server business logic for mail classification.

Error when I send email SparkPost

First the "email send" works fine but now It doesn't work anymore and when I print the error this is the text:
ERRORE {"name":"SparkPostError","errors":[{"message":"Message generation rejected","description":"Exceed Sending Limit (sandbox)","code":"1902"}],"statusCode":400}
Anyone can explein me how I'm wroing?
This error says that you have reached the limit of messages sent from sparkpostbox.com and now must register your own sending domain. You can read about how to do that here.
Each new SparkPost account may send a fixed number of messages addressed 'From:' sparkpostbox.com. After that, the idea is that you register your own sending domain and send from that instead.
The sandbox options allows you to send using the #sparkpostbox.com domain. It is currently limited to 50 sends for the lifetime of the account. At this time you should have a verified sending domain to use going forward. If you are looking for information on testing using SparkPost, take a look at this support document: https://support.sparkpost.com/customer/portal/articles/2361300
Source of the answer for your question is there: Error "Fatal SparkPostError: Exceed Sending Limit" when sandbox=true

Spring JavaMailSenderImpl logs into SMTP server every time for sending emails, causing latency in web application

I am using Google's SMTP server to send transactional emails from my web application, using Spring's JavaMailSenderImpl class.
The problem is: the send Email function send(SimpleMailMessage simpleMessage), is authenticating on the SMTP for every email. This is slowing down the web server, as I am sending the emails synchronously (which is of course a bad idea, I should rather be sending the emails asynchronously using a queue.)Nevertheless my question is:
Is there a way to save the SMTP auhenitcation during the first email and use it for all the subsequent emails.
Use the method send(SimpleMailMessage[] messages) of JavaMailSenderImpl. It will reuse the same transport for each message.

Error sending email

I created a simple application at: graficaromana.com.br
In the contact form (http://graficaromana.com.br/Contato) when I try to send an email I get an error.
Locally the mail is sent normally without any error.
Is there some setting I have to do on the host? in the domain?
Error:
System.Net.Sockets.SocketException A connection attempt failed because
the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to
respond 209.85.225.108:25
See the code for more details in link: https://gist.github.com/1149028
looks like the remote host has maybe a separate server they use for sending mail out or that you have to be whitelisted with the host in order to send mail and a username and password may be required. have not looked at your code but i see them kind of errors when there is a firewall involved and the machine trying to send does not have access through the firewall, as the firewall does not respond at all you get an answer like ' The server did not respond in a timely manner' or 'the server did not respond after a certain amount of time' i am assuming that before you posted on here that you have asked the hosting provider about sending mail, and what there preference is on how this should be carried out? right?
if so please provide info on what they have said
here is a sample of code to send email:
var smtpClient = new SmtpClient();
var message = new MailMessage();
smtpClient.port = 25;
message.from = "test#test.com";
message.To.Add("me#workemail.com,client#office.com";
message.Subject = "Contact from website";
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>TEST</body></html>"
try {
smtpClient.Host = "relay.server.you.have.from.host";
smtpClient.Send(message);
} catch( Exception ) {
// host is down or we are local try other servers
// here you can have more try / catch
smtpClient.Host = "127.0.0.1"
smtpClient.Send(message);
}

Resources