2

I have a problem while sending a message via Jersey client on Mandrill API. I use Jersey client as follows:

ClientBuilder.newClient()
                    .register(JacksonJsonProvider.class)
                    .target(“https://mandrillapp.com/api/1.0/messages/send.json”)
                    .request(MediaType.APPLICATION_JSON_TYPE)
                    .post(Entity.json(methodEntity));

Below you can see logged headers, method and content of the API request.

POST https://mandrillapp.com/api/1.0/messages/send.json
Accept: application/json
Content-Type: application/json
{"message":{"subject":"Hello World!","text":"Really, Im just saying hi from Mandrill!","to":[{"email":"marcel@xxxx.com","name":"Marcel cccc","type":"to"}],"headers":{},"tags":["test"],"from_email":"info@xxxxx.com","auto_text":true,"preserve_recipients":false},"async":false,"key":"EWIBVEIOVBVOIEBWIOVEB"}

In response to this request I keep receiving following message:

[{"email":"marcel@XXXX.com","status":"rejected","_id":"0ea5e40fc2f3413ba85b765acdc5f17a","reject_reason":"invalid-sender"}]

I do not know what the issue may be, from some posts I figured out I must use UTF-8 to encode my message and headers. But setting encoding to UTF-8 did not do much good. Otherwise the payload seems fine to me and moreover I found on forums that invalid sender can mean any other kind of issue (not just invalid sender which is sad).

Andy
  • 49,085
  • 60
  • 166
  • 233
Petr Chudanic
  • 547
  • 4
  • 12

1 Answers1

3

I had exactly same problem with

"reject_reason":"invalid-sender"

You probably check already similar question Mandrill “reject_reason”: “invalid-sender”

Try it if it helps. I realize that you also missing header parameter in your request

e.g. User-Agent: Mandrill-myclient/1.0

Please try also add this parameter to your Jersey Client setup as following:

       ClientBuilder.newClient()
                .register(JacksonJsonProvider.class)
                .target(“https://mandrillapp.com/api/1.0/messages/send.json”)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .header("User-Agent", "Mandrill-myclient/1.0")
                .post(Entity.json(methodEntity));

Does it help?

Community
  • 1
  • 1
Mr.B
  • 91
  • 2