I am sure many asked the same question but I can't find an answer that is comprehensive.
We are running a web app (myapp.com) on an EC2 instance deployed on the Sydney region. The app sends emails via AWS SES. Because SES is not available in Sydney, we have configured SES in Oregon. We generated the SMTP credentials and configured our Springboot application to send emails using these credentials. We are able to send the email and the email gets delivered successfully but it goes to the SPAM folder.
The email from address is: noreply#myapp.com
We have verified the domain name in the SES console
We have verified the noreply#myapp.com email address in the SES console
DKIM is also turned on and verified
However,
We are not sure why the email keep getting delivered to the SPAM folder.
When I viewed the RAW email message I can see the SPF header:
SPF: NEUTRAL with IP xx.xx.xx.xxx
I haven't configured any SPF record in my DNS name but as I understand it I don't need to because I am using SES SMTP server and not custom MAIL FROM.
I am at lost as to why the email is getting delivered to SPAM.
Can any one help?
Solved the issue.
I am not sure exactly what was happening, but when using the SpringBoot JavaMailSenderImpl to send emails using AWS SES, all emails were not being signed using DKIM (no DKIM headers on the outgoing email messages). This was causing some SMTP servers to treat our emails as SPAM.
I have resolved the issue by using Java Mail API (javax.mail) to send emails and once I've done that then all email messages are delivered with DKIM header and non of them went to the SPAM folder (tested against Gmail and Outlook).
Again, I am not sure why using SpringBoot JavaMailSenderImpl was causing the issue. My understanding is that the JavaMailSenderImpl uses Java Mail behind the scene but for some reason non of the emails contained the DKIM header.
Below is my email sender using Java Mail if it's going to help anyone out there.
try {
Properties properties = new Properties();
// get property to indicate if SMTP server needs authentication
boolean authRequired = true;
properties.put("mail.smtp.auth", authRequired);
properties.put("mail.smtp.host", "ses smtp hostname");
properties.put("mail.smtp.port", 25);
properties.put("mail.smtp.connectiontimeout", 10000);
properties.put("mail.smtp.timeout", 10000);
properties.put("mail.smtp.starttls.enable", false);
properties.put("mail.smtp.starttls.required", false);
Session session;
if (authRequired) {
session = Session.getInstance(properties, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("ses_username","ses_password");
}
});
} else {
session = Session.getDefaultInstance(properties);
}
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("from#example.com"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to#example.com"));
message.setSubject("This is a test subject");
Multipart multipart = new MimeMultipart();
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent("This is test content", "text/html");
htmlPart.setDisposition(BodyPart.INLINE);
multipart.addBodyPart(htmlPart);
message.setContent(multipart);
Transport.send(message);
} catch (Exception e) {
//deal with errors
}
Related
I am trying to send an email from my Firebase Cloud Functions using the SendGrid's mail client for Node.js
I am following their example described as follows:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(functions.config().sendgrid.key);
const msg = {
to: 'my_own_mail#gmail.com',
from: 'my_other_own_mail#gmail.com',
subject: 'Sending with Twilio SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
Once the function is fired, everything gets executed successfully. In my function logs I get Status 202 and the actual mail gets delivered but not in the main mailbox but rather in the Spam folder. When I open the message, it simply says:
I don't really understand what is the problem.
NOTE: If I send the message to an Yahoo email it doesn't go in the Spam folder. Same applies if I send it to my business email.
Your problem is not related to cloud functions or the code, there are a few anti-spam rules you need to follow, this gave me a good starting point
Sendgrid does not send your messages to the SPAM folder it all depends on the recipients mail delivery flow spam filters.
Most messages are marked as spam for one of the following reasons
1. Message is not authenticated properly
Validated that your message is authenticated properly with SPF or DKIM
2.Your message originates from an IP that is in a Blacklist (this might be on Sendgrid's)
Try by sending a message to your self and open the message headers , then look for entries like the one below
Received: from xxxxxxxxx.com (xxxxxxx.com [xxx.xx.xxx.xx])
by xxxx.com with SMTPS id ##############
The IP between [] is the sending server IP try to use public blacklist such as spamhaus to see if it is blacklisted and report to Sendrig if you find a match
3.The content of your message has known phishing techniques (accidentally or not)
Check the "Format your mail" section for Gmail senders guidelines as general recommendation
i am trying to setup mails on my VestaCP, i have made MX, Dmarc records, followed every guide about these records on google but there are 2 problems.
Here is my mxtoolbox results
https://mxtoolbox.com/domain/letsupload.co/
=======
1st Problem -/
The first problem is that all my mails sent from contact#letsupload.co are sent into spam folders, though i created all required records.
2nd Problem -/
I can send emails from my webmail but i cant receive them, when i send email from gmail it gets sent, there is no error that my email was not delivered but i dont receive it in my webmail.
Please help me out.
You will find that not many people will help because of the lack of code. Just always make sure that when you ask a question like this wondering why something isn't working, you provide code so people can pin point a problem. Stack Overflow don't put that page there before you ask a question because they think you're stupid, they do it so you can get a more specific and the best response to your question. So just make sure you give this a look.
However, I had a similar issue before where all my mails were being sent to the spam folder and they're a few things that could be the cause:
Mail Client Reverse DNS Checks: You mentioned that you are using a personal domain but one thing to remember is that your domain will have its on DNS server.e.g. if you are with GoDaddy that would be the default DNS setting. So the problem is that when you send an email to lets say a #outlook.com email server the mail client of the recipient will do a reverse DNS check. So it realises that you are sending to an #outlook.com but the email is coming from #letsupload.co. So it realises that you are sending from an IP that isn't related to the domain you sending to and that is what SPAM is! Like I said without seeing your code I can't exactly know how to help but if you aren't aready using a mail server with Authentication enabled that could be a cause. Try using a server with authentication and add this code:
// I am using $mail as my instance of PHPMailer
$mail->Host = 'your-new-server-with-authentication';
$mail->Port = 587; // usually the default port (double check though)
$mail->SMTPAuth = true;
// now define the username and password for your mail server
$mail->Username = 'your-username#mailserver.com';
$mail->Password = 'OpenSesame123';
Reply to: You can also try adding a reply-to email address. Some mail servers tend to put emails in spam that don't have a reply email address to stop bots from spamming a person's email account. So try adding this if you haven't already:
// I am using $mail as my instance of the PHPMailer
$mail->AddReplyTo('youremail#domain.com');
Implementing SPF: If the above to fail then the chances are that you need to implement SPF. You can learn all about this from an expert on the subject gr8gonzo here is the tutorial and article he wrote on the subject. That will not only just help with implementing SPF but also with the best practises for when you're sending emails.
I am creating a webservice with Mailgun to send out emails. It will BCC my own domain's email for every email sent out. Assuming my domain is "example.com". For every email sent out to a customer, say, customer1#gmail.com, I will BCC its content to sales#example.com.
Currently, the domain example.com and its email is hosted on a server with CPanel.
In Mailgun, I have added and verified the domain example.com. Using this domain, I've sent a mail to customer1#gmail.com and sales#example.com. The email is sent without issues to Gmail, however when sending to sales#example.com, I keep getting the error Server response: 550 550 Verification failed for <bounce+e0f051.e0179a-sales=example.com#example.com> No Such User Here.
What's baffling here is that if i send the email via Mailgun with another verified domain such as anotherexample.com, and then using this, I send my mail to sales#example.com. The email arrives perfectly fine without errors.
So far, the things I've tried:
Added Mailgun suggested SPF and DKIM
Modified SPF to include my CPanel server's IP (together with Mailgun SPF)
Deleted both the SPF and DKIM (one at a time and both at once)
Verified that the email sales#example.com exists. Using the CPanel webmail's interface, I can send and receive emails just fine.
Tried updating the CPanel MX entries Email routing from Local -> Automatic -> Remote. ("Local" works the best. If its set to "Remote", email sending and receiving doesnt work at all, even if mails are sent through Gmail/Hotmail).
My current MX settings are:
Priority 0: mail.example.com
My current Zone file records on CPanel:
example.com A <some ip>
mail.example.com A <same ip as above>
The code I am using to send mails via Mailgun (Ruby):
mg_client = Mailgun::Client.new 'xxxxxxxxxxx'
message_params = {:from => from_email,
:to => customer.email,
:bcc => bcc_email,
:subject => MessageTemplate.email_subject,
:text => message}
result = mg_client.send_message('example.com', message_params).to_h!
I currently do not have the SPF and DKIM records in the zone files. I've added and removed them and they had no effect on the error (still delivers fine to Gmail too).
I've spend the whole on this, scouring forums and whatnot but can't seem to find a solution.
If at all relevant, I have a 301 redirect of example.com to www.example.com(Which has a CNAME pointing to another server). But I've researched and found out that 301 redirect does not affect emails.
I don't think this is a send-side problem. You're sending to sales#example.com, but you're getting errors relating to bounce+e0f051.e0179a-sales=example.com#example.com, which is a typical VERP address. Now, VERP addresses are fine, so long as you're expecting them. Given that you are not apparently providing that explicit address to MailGun, I assume that they are generating that address automatically. I would check their documentation for how they generate return-path (envelope sender) addresses, and either override the sender address (with just sales#example.com), or configure handling of those VERP addresses on your own inbound mail server.
Here is a mailgun explanation
This error occurs due to what is termed Sender Address Verification (SAV). During SAV, an email server performs an MX lookup upon the domain (example.com) listed within the message envelope's Mail-From field. SAV typically rejects the message if,
the sender's (in this case, Mailgun's) MX records are not configured for that domain AND
the domain of the message envelope's Mail-From field does not match the domain of the message header's From field.
https://help.mailgun.com/hc/en-us/articles/360011804533-Sender-Verification-Error
i am facing a problem when i send email using cakephp3 on my hosting. Emails are being sent but when i view the recieved email in browser i see this along with the email address from i'm sending the email
From: no-reply#mail.com via cp-in-12.webhostbox.net
However when i check mail in phone's gmail client 'via cp-in-12.webhostbox.net' does not shows up.
Here is my code
$email = new Email('default');
$email->from(['no-reply#mail.com' => 'no-reply#mail.com'])
->to('mymail#gmail.com')
->subject('Test Mail')
->send('Thank You! for purchase! its a test mail');
}
Please help.
Thank You
Google appends the "via mail.domain.com" when the sending domain does not have any sort of SPF records on it. It's to notify users that the email may not have originated from the "From" email address' domain, but since you don't have any restrictions (set by SPF), Google can't tell if you're a bad guy, or just haven't set up your records yet. You're going to want to either setup some SPF and DKIM records (check with your webhost on how to do that), and that should eliminate those messages. The reason it doesn't appear on iPhone is because that platform does not have that feature.
I'm trying to send emails via Javamail to a corporate account. My Java test app works fine when I send message to gmail and my personal email. I can also successfully send to the corporate account via my email hosting webmail client.
I've read through posts here and have tried setting -Djava.net.preferIPv4Stack=true in the VM for the test app but it did not work.
I have checked the junk mail at the corporate client and the message is not there. That is not to say its not being blocked elsewhere at the corporate site.
Any ideas what can be causing this problem?
I'm using org.apache.commons.mail.HmtlEmail and this is the test code:
// Create the email message
HtmlEmail email = new HtmlEmail();
email.setHostName(smtpHost);
email.setAuthenticator(new DefaultAuthenticator(smtpUser, smtpPwd));
email.setSSLOnConnect(true);
email.addTo(to);
email.setFrom(from);
email.setSubject(subject);
// set the html message
email.setHtmlMsg(text);
// set the alternative message
email.setTextMsg("Your email client does not support HTML messages");
// send the email
email.send();
So #Bill's question regarding Javamail debug output got me thinking about the content of the email message. The debug log shows all is fine but what I found was I included Bootstrap and Fontawsome JS / CSS links in the email header and that caused the message to be rejected by the corporate system for security reasons presumably. Thanks for the help