23

I'm trying to send emails using mandrill email service but I get the following error

    Full Response
[
    {
        "email": "someemail@somedomain.com",
        "status": "rejected",
        "_id": "b814c2974594466cba9c904c54dca6c6",
        "reject_reason": "invalid-sender"
    }
]

Apart from the above error there is no more details about it. we are using .net to send emails with Mandrill SMTP settings.

S M Azam
  • 343
  • 1
  • 2
  • 5
  • 3
    you need to provide a `from` field in addition to `to`, `subject` and `html`. I was getting this error with [nodemailer-mandrill-transport](https://github.com/RebelMail/nodemailer-mandrill-transport) – Connor Leech Jun 25 '15 at 06:44

6 Answers6

15

It'd be useful to see the call/email that's being sent. That error means that there's an invalid sender, as indicated in the reject reason field. That could be because of an invalid email address, invalidly-encoded from name, or invalid or broken encoding in other headers making it so that Mandrill can't parse the "from" header, but without seeing the actual email that you're sending, it's hard to say for sure exactly what the issue is.

You probably want to check that there's a fully-qualified domain name in the from email address, and that if the subject line is encoded, there aren't things like newline (\n) characters that break multibyte characters in the subject line. If you aren't able to identify the issue in the raw SMTP message, feel free to get in touch with support for further troubleshooting assistance.

Kaitlin
  • 6,167
  • 32
  • 30
  • 1
    The actual answer do not solve the problem. The problem is .NET message encoding. So, Mandrill can actually do better if it would indicate the parse errors. I wonder why this answer is accepted. – Pavel Korsukov Oct 01 '16 at 11:42
14

I had the same problem, in my case, I had forgotten to complete the template defaults "From Name" and "Subject".

user3524762
  • 582
  • 4
  • 15
  • I know it's an old answer, but this was exactly my problem. Had set the From Address and From Name, but forgot to hit Publish. – tones Apr 16 '18 at 09:10
  • Years later I had the same issue, my subject was "-" and it was rejecting with a invalid sender error. – Rafael Feb 17 '21 at 12:03
5

I had the same problem. In my case encoding in headers was the problem. I did change the headers encoding to UTF-8 and it worked. I was using C# SMTP and the code is below.

message.HeadersEncoding = Encoding.UTF8;

Hope it works!

ali
  • 1,301
  • 10
  • 12
  • For me, adding this line of code didn't work. After hours of trial and error, I found out that I had a hyphen in my subject line. – Saeed Neamati Aug 05 '16 at 04:50
0

For me, it was because my emails were coming from email@example.net1 Mandrill rejected me because of the 1 at the end. e+mail@example.net and email@example.neta are both valid and will be accepted.

My other tests just had blank From headers, so they were rejected as well. I didn't even realize these emails were being received by Mandrill until I logged in and checked the API logs.

Captain Hypertext
  • 2,446
  • 4
  • 27
  • 36
0

I've had a similar problem recently. It was due to my use of certain characters in the message.from_name field. After searching through documentation and stack overflow, I couldn't find a list of forbidden characters, so although this doesn't necessarily pertain to your case, I thought I'd share this small list I compiled of some acceptable characters (not an exhaustive list):

  • a-z
  • A-Z
  • 0-9
  • _, -, !, #, $, %, \, ^, &, *, +, =, {, }, ?, .

In JS, here's a RegExp that will match with forbidden characters (or, rather, any characters that aren't in the aforementioned list):

const pattern = /[^a-zA-Z0-9_\-!#$%\^&*+={}?.]/;

Hope this is helpful for anyone else stuck on this.

0

If you use .NET SmtpClient, may be this is because of bug on it: https://social.msdn.microsoft.com/Forums/vstudio/en-US/4d1c1752-70ba-420a-9510-8fb4aa6da046/subject-encoding-on-smtpclientmailmessage

Workaround, that helped us:

use

message.SubjectEncoding = Encoding.Unicode;

instead of

message.SubjectEncoding = Encoding.UTF8;

This is still actual in .Net Framework 4.7.2

Ruslan K.
  • 1,912
  • 1
  • 15
  • 18