GithubHelp home page GithubHelp logo

lutung's People

Contributors

adnansorg avatar aldenquimby avatar bcolyn-ngdata avatar billoneil avatar cemu avatar eweatherley avatar frankleonrose avatar gitter-badger avatar jell0wed avatar landbaychrisburrell avatar lokesh-github123 avatar matoushybl avatar maurociancio avatar nwolff avatar oglowo avatar rhodeidra avatar romalefrancois avatar rschreijer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lutung's Issues

Test Inbound API Functions

I have no inbound-emailing set up with Mandrill. Would be great if anyone out there could test the implemented 'inbound' functionalities.

In MandrillInboundApi.java

Unable to send mail while using Play Framework. Works perfectly well in a normal maven Java Project

I am trying to integrate lutung with the Play Framework. The Play version is 2.4. The build.sbt is as below:

"com.google.code.gson" % "gson" % "2.3.1",
"org.apache.httpcomponents" % "httpclient" % "4.0-alpha4",
"commons-io" % "commons-io" % "1.3.2",
"commons-logging" % "commons-logging" % "1.1.1",
"com.mandrillapp.wrapper.lutung" % "lutung" % "0.0.4"

And the code to send mail is exactly the same as the one shown in Examples section of the repo at https://github.com/rschreijer/lutung. I am getting an Internal Server error 500. The detailed trace:
com.microtripit.mandrillapp.lutung.model.MandrillApiError: Unexpected http status in response: 500 (Internal Server Error)
at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:64)
at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:45)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:99)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:54)
at controllers.MongoStore.sendMandrill(MongoStore.java:63)
at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply

The same code is working fine when i build a normal maven java (No Play Framework)project. What am i missing here?

lutung jar artefact contains log4j.xml

I see that there is a log4j.xml file in src/main/resources.

This causes the file to be included in the main artefact as deployed to maven central. However, since log4j loads log4j.xml in preference to log4j.properties, lutung effectively hijacks the logging of the (rather large, properties-file-logging based) project i'm working at.

A library should not contain logging configuration on its own. If any logging is needed for unit tests, logging configuration should go in src/test/resources.

Issue NON-Issue

Referring to issue #4
Metadata from /messages/search.json not mapped

Not real issue. The issue is that the code is commented out. Just uncomment your code for metadata in MandrillMessageInfo.java. It is working fine. Just remember that you have to configure your metadatas in your Mandrill account, otherwise they won't be shown or saved at all.

MandrillRequestDispatcher.execute throwing NPE

After upgrading to version 0.0.8 I started to have some NPE at line 124 of MandrillRequestDispatcher, this is because response is null at this point. Is there any workaround for this or a way to debug my request in order to figure out what is going on? Many thanks.

Can I print the whole email message as json upon sending it?

Hello,

First I would thank you so much for this good work.

I am using this library to send template emails to users, I am already defined many templates in mandrill and I am just passing the handlebars tags from the api here, but for some reason the template email is received but without replacing the variables {{}} by the value that I am sending, hence the merge tags are not working, for this reason I am looking for a method to print the whole json message after sending the email so I can analyse it to see what is the problem and why the merge tags are not working.

So is there any way to print the whole json after this operation?

MandrillMessageStatus[] messageStatusReports = mandrillApi.messages().sendTemplate("test-template", template_content, message, false);

Impossible to send a mail via template api ?

Hey,

I see the way to create template through your library, but can't find any method to send a mail with an email template name ?
Not implemented yet ?

Mandrill api reference : /messages/send-template.json

Template Vars

Hi

Does the library support local variables for Mandrill Templates

example

"global_merge_vars": [
            {
                "name": "merge1",
                "content": "merge1 content"
            }
        ],
        "merge_vars": [
            {
                "rcpt": "[email protected]",
                "vars": [
                    {
                        "name": "merge2",
                        "content": "merge2 content"
                    }
                ]
            }
        ],

500 internal server error

I used to have mail sending through http working lutung version 0.0.2-snapshot.

After a long idle time on the app, i retry sending email from my app through lutung http api again, but it now it throws internal server error.
After upgrading to the latest 0.0.5, it throws the same exception.

Here's the trace:

Exception: com.microtripit.mandrillapp.lutung.model.MandrillApiError: Unexpected http status in response: 500 (Internal Server Error)
at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:92)
at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:46)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.sendTemplate(MandrillMessagesApi.java:206)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.sendTemplate(MandrillMessagesApi.java:133)

It used to work, so it shouldnt be about the api key or something, as i havent changed the key or anything.

What might be wrong and how do i debug it ?

Here's my code :

MandrillMessage message = this.createMessage(
    mailMsg.getSubject(), // the email subject / title
    ADMIN_MAIL,  // my email
    mailMsg.getVar().getDomainName() + " Admin" 
);
message.setGlobalMergeVars(this.createMergeVars(mailMsg));
message.setTo(this.createRecipients(mailMsg.getRecipients()));
message.setTags(mailMsg.getTags());

// hard code the api key here
MandrillApi mandrillApi = new MandrillApi(API_KEY);
MandrillMessageStatus[] messageStatusReports = null;
try {
    messageStatusReports = mandrillApi.messages().sendTemplate(
        mailMsg.getTemplate(), 
        null, // we got no block contents like mailchimp's templat layout 
        message, 
        false // it'll become true automatically if there're lots of recipients
    );
} catch(Exception e) {
  ...
}

return messageStatusReports;

Thanks a lot !

MergeVar & arrays

Hi,

I'm working on transferring an orderline list to a template.
It seems that the list itself is well seen (it render the correct amount of order line) but it can't reach the content of them (and so the content of those line is empty).

Helas I find that case as example nowhere.

Here's the MergeVar filling code (simplified) :

ArrayList<MergeVar[]> products = new ArrayList<MergeVar[]>();
for (CartLine ol : cart.getCartLine()) {
`` ``MergeVar[] product = new MergeVar[4]; `` ``product[0] = new MergeVar("img", String.valueOf(ol.getEan())); `` ``product[1] = new MergeVar("author", "author"); `` ``product[2] = new MergeVar("bktitle", "title"); `` ``product[3] = new MergeVar("price", String.valueOf(ol.getPrice() * ol.getQuantity())); `` `` products.add(product);
}

MergeVar[] mergeValues = new MergeVar[4];
mergeValues[0] = new MergeVar("orderdate", new SimpleDateFormat("dd/MM/yyyy HH:mm").format(Calendar.getInstance().getTime()));
mergeValues[1] = new MergeVar("order", String.valueOf(15654));
mergeValues[2] = new MergeVar("total", 22.5);
mergeValues[3] = new MergeVar("products", products);

...

Template :
{{#each products}}
<tr>
<td width="120"><img src="{{img}}" width="80" height="120"/></td>
<td>{{author}} - {{bktitle}}</td>
<td width="50" align="right">€{{price}}</td>
</tr>
{{/each}}

And here the result with two products
image

Does anyone can say where I'm wrong ?

Thanks a lot in advance,
Congrats for the API (which is good),
Sorry for my english (which is bad).

Geoffrey

Escaping HashMaps

I am trying to send a message trhough 'send-template.json' but what is being sent is an encoded string, how can i fix this??

{
"message": {
"to": [
{
"email": "[email protected]",
"type": "to"
}
],
"inline_css": true,
"merge_vars": [
{
"rcpt": "[email protected]",
"vars": [
{
"name": "url",
"content": "{"Parent":{"Test":"String"}}"
}
]
}
]
},
"template_content": [
{
"name": "satisfy_validation",
"content": ""
}
],
"template_name": "TemplateName",
"async": true,
"key": "-------"
}

500 Internal Error when I send a template with ipPool and sentAt params

When I send without those params, it works correctly, but if I put them I'm getting this:

ipPool = null
sentAt is a correct Date object

com.microtripit.mandrillapp.lutung.model.MandrillApiError: Unexpected http status in response: 500 (Internal Server Error)
at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:64)
at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:45)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.sendTemplate(MandrillMessagesApi.java:211)

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

Hi,

I just cloned your library and was trying to test it using the sample code you've written in the Readme file for the project.

However, after putting the Mandrill API key, when I ran the application, it gave an exception javax.net.ssl.SSLPeerUnverifiedException with the message peer not authenticated.

Here's the stacktrace for the exception —

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:126)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:572)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
    at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:45)
    at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:45)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:99)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:54)
    at com.microtripit.mandrillapp.lutung.SimpleMailTest.main(SimpleMailTest.java:52)

Any idea what I might be doing wrong?

"Failed to parse response from request"

I am trying to send my template
messages().sendTemplate("WelcomeTest", null, message, Boolean.TRUE);
I do receive mail as expected but on return "Failed to parse response from request". So I cant 100% be sure if the mail passed or not. Can it be fixed? (I also tried to figured/fix why its happened but unfortunately I cant debug your tests they always get skiped when I run them)
Thanks for help

Attachment in Email comes with corrupted data..

First of thanks for the wonderful API. It covers many scenarios which mandrill provides.

Now, coming on the issue: I am trying to send an email with attachment, and for that I am using "MandrillMessage.MessageContent" class. The code I have used is:

            List<MandrillMessage.MessageContent> attachments = new ArrayList<MandrillMessage.MessageContent>();

            MandrillMessage.MessageContent messageContent = new MandrillMessage.MessageContent();

            messageContent.setContent("test");
            messageContent.setType("text/plain");
            messageContent.setName("name.txt");

            attachments.add(messageContent);

        message.setAttachments(attachments); // Here message is "MandrillMessage" 

so, this is the simplest case, and when I send mail using this attachment, the mail sent successfully and at the other end I received a mail with attachment but the data in attachment is all corrupted and not the one which I have set.

Can you please help me resolving this.

Thanks in advance,
Jaydatt

MergeVar Content attribute should be an object

@rschreijer MergeVar Content attribute should be of type Object so in this way i could insert different objects in order to create generic templates and add more complexity to them.

I think this is an issue because if i use gson to convert, lets say, a map and set it to a merge var, the api will parse that string again encoding the map and leaving it useless:

ex:

at my code: "{"key":"value"}"
second time in the api side: "{"key":"value"}"

Submit to maven repository?

Would you consider submitting this to the central Maven repository? It'd be terribly convenient to just do this when trying to use it:

    <dependency>
        <groupId>com.mandrillapp.wrapper.lutung</groupId>
        <artifactId>lutung</artifactId>
        <version>0.0.3-SNAPSHOT</version>
    </dependency>

Or is it somewhere that I'm just not seeing, possibly under a different name?

Send with async flag not behaving as expected

The MandrillApi class' send message accepts a async flag. However, even if I pass in true for it, the execution thread waits for the mails to be dispatched. Setting the flag to false behaves the same as well.

Is there some other settings required to be made for dispatching the mails in an asynchronous manner?

Actual exceptions on requests to Mandrill server are not propagated

The execute() method of MandrillRequestDispatcher has a bug: If the request to Mandrill fails for some reason, the response object gets null. This in turn leads to a NPE in the finally block. When the method is finally left with the NPE, the original exception cause is gone - making debugging very hard.
This codesmell is also detected by SonarLint, by the way.

PR is incoming.

See also: https://next.sonarqube.com/sonarqube/coding_rules#rule_key=csharpsquid%3AS1163

Ability to add CC to the MandrillMessage.

Hello,

I am developing an application an I need to include some email addresses to the CC section of the message.

Looking around at the Mandrill API Docs, I only found support for TO and BCC. Is there any workaround to this? If not, are you open to pull requests for such a feature?

Thanks,
codelirium

still maintained?

there are a couple of open PRs with no reaction from @rschreijer or @billoneil so the question is whether Lutung is still maintained or if we better use something else...

Please remove "final class" to enable mocking?

I am writing some unit tests of my integration code and am attempting to mock MandrillMessageApi and the sendTemplate method. There are very few mock frameworks which are capable of working with final methods and classes.

Would you consider removing the final nature of the API classes so these APIs could be mocked in unit tests?

MandrillMessagesApi.sendRaw() not working

So far, I failed to successfully use Mandrills /messages/send-raw.json call. I'm not sure if I fail to create valid MIME contents, but lemme know if you make any experience with this call.

400 Bad request error after couple of days

Since a couple of weeks we are experiencing an issue with the library. After a couple a days of activity, sending email become impossible because of a HTTP 400 error.

This is the stack trace I have.
`java.lang.Exception: Email has not been sent. Miss use of the sender service : com.microtripit.mandrillapp.lutung.model.MandrillApiError: Unexpected http status in response: 400 (Bad request). Unparsable JSON response =

400 Bad request


Your browser sent an invalid request.

`

Restarting the server (jetty) solve the issue.
It's not an issue with the mandrill API because we have over application components sending email through Mandrill API without issue.

Add messages/info method support

public final MandrillMessageInfo info(
final String messageId)
throws MandrillApiError, IOException {
final HashMap<String,Object> params = MandrillUtil.paramsWithKey(key);
if(messageId != null) {
params.put("id", messageId);
}
return MandrillUtil.query(rootUrl+ "messages/info.json",
params, MandrillMessageInfo.class);
}

java.lang.NoSuchMethodError in RequestDispatcher

Using the send() method, I get an exception when sending any message:

java.lang.NoSuchMethodError: No static method consume(Lorg/apache/http/HttpEntity;)V in class Lorg/apache/http/util/EntityUtils; or its super classes (declaration of 'org.apache.http.util.EntityUtils' appears in /system/framework/ext.jar) at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:104)

Error parsing error from mandrill

The requestdispatcher tries to read a json formatted error from a response with error status code. But the response does not contain a json formatted error. Please throw in this case an exception with the original body content.

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:803)
at com.google.gson.Gson.fromJson(Gson.java:768)
at com.google.gson.Gson.fromJson(Gson.java:717)
at com.google.gson.Gson.fromJson(Gson.java:689)
at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:62)
at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:45)
at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.search(MandrillMessagesApi.java:239)
at ....mycode....
at ....mycode....
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:374)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)
... 11 more

Parsing raw messages don't handle headers with multiple values

I've noticed that when asking Mandrill to parse a raw email the headers attribute in the response cannot always be deserialised. Values for a given header can be a string or an array.

Headers with multiple values cannot be deserialised into a MandrillMessage since header values are only expected to be strings.

As an example;

A response from the Mandrill parse request:

{
  ...
  "headers": {
    "Return-Path": "<[email protected]>",
    "Received": [
      "from mail123.google.com (mail.google.com [123.123.123]) by inbound-smtp.eu-west-1.amazonaws.com with SMTP id 23456 for [email protected]; Fri, 15 Jun 2018 09:30:43 +0000 (UTC)",
      "by mail123.google.com with SMTP id 1234 for <[email protected]>; Fri, 15 Jun 2018 02:30:43 -0700 (PDT)"
    ],
  ...
}

The library then throws the following:

Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 70 path $.headers.
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
	at com.google.gson.Gson.fromJson(Gson.java:888)
	at com.google.gson.Gson.fromJson(Gson.java:853)
	at com.google.gson.Gson.fromJson(Gson.java:802)
	at com.google.gson.Gson.fromJson(Gson.java:774)
	at com.microtripit.mandrillapp.lutung.model.MandrillRequest.handleResponse(MandrillRequest.java:64)
	... 8 more
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 70 path $.headers.
	at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825)
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:401)
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:389)

I am potentially able to raise a PR that fixes this but will want a release with the fix fairly quickly. Will see how I get on.

Failed parsing mandrill error, as far as I can tell

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
    at com.google.gson.Gson.fromJson(Gson.java:803)
    at com.google.gson.Gson.fromJson(Gson.java:768)
    at com.google.gson.Gson.fromJson(Gson.java:717)
    at com.google.gson.Gson.fromJson(Gson.java:689)
    at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:62)
    at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:45)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.sendTemplate(MandrillMessagesApi.java:211)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.sendTemplate(MandrillMessagesApi.java:138)

Remove commons logging

It is painful that this library brings in commons-logging and log4j, especially when it's only used for debugging.

It would be much cleaner to make the dependencies <optional>true</optional>, and add a simple wrapper around logging that only calls commons-logging if it exists.

Also imho, slf4j would be make more sense than commons-logging, but as long as the dependency is optional, doesn't really matter I suppose.

Template rendering returns plain template

I think this is more a Mandrill issue than a library one (since I had a similar issue with a PHP library), however, it would be good to get some insight into what I could potentially be doing wrong.

Sending with a template works as expected, and the handlebar variables are replaced correctly. When asking for a rendered template, however, the API returns the correct template, but with no variables replaced.

Here's my implementation (ignore the verboseness of some components, this is still very much in development!)

public String sendEmail(MemberDO member) throws MandrillApiError, IOException
{
    final MergeVar[] mergeValues = { new MergeVar("member_first_name", member.getFirstName()),
            new MergeVar("member_grade", member.getType().toString()), new MergeVar("member_number", member.getMembershipNumber()),
            new MergeVar("initial_password", "still in development"),
            new MergeVar("sponsor_info", member.getType().equals(MemberType.SPONSOR)) };

    final Map<String, String> templateContent = new HashMap<String, String>();
    for (MergeVar value : mergeValues)
    {
        templateContent.put(value.getName(), value.getContent().toString());
    }

    final String emailTo = member.getEmail();

    final MergeVarBucket mergeBucket = new MergeVarBucket();
    mergeBucket.setRcpt(emailTo);
    mergeBucket.setVars(mergeValues);

    final List<MergeVarBucket> mergeBuckets = new ArrayList<MergeVarBucket>();
    mergeBuckets.add(mergeBucket);

    final Recipient recipient = new Recipient();
    recipient.setEmail(emailTo);

    final List<Recipient> recipients = new ArrayList<Recipient>();
    recipients.add(recipient);

    final MandrillMessage message = new MandrillMessage();
    message.setTo(recipients);
    message.setMergeLanguage("handlebars");
    message.setMergeVars(mergeBuckets);

    final String render = mandrill.templates().render("welcome", templateContent, templateContent);
    final MandrillMessageStatus[] deliveries = mandrill.messages().sendTemplate("welcome", templateContent, message, false);
    return null; // render or delivery status
}

Unsupported cookie spec on Hello World Example

Explanation

I attempted to run the HelloWorld example from the readme and received an "Unsupported cookie spec" error at the line ...

MandrillMessageStatus[] messageStatusReports = mandrillApi
        .messages().send(message, false);

Failed Source Code

//Initiate Mandrill
MandrillApi mandrillApi = new MandrillApi("<My API Key>");

//Build Message
MandrillMessage message = new MandrillMessage();
message.setSubject("Hello World!!");
message.setHtml("<h1>Hi pal!</h1><br />Really, I'm just saying hi!");
message.setFromEmail("[email protected]");
message.setFromName("Stephan Rayner Personal Email");

//Build Recipients
ArrayList<Recipient> recipients = new ArrayList<Recipient>();
Recipient recipient = new Recipient();
recipient.setEmail("[email protected]");
recipient.setName("Stephan Rayner Work Email");
recipients.add(recipient);

/*This is where you add more*/

// Attach Recipients to message
message.setTo(recipients);
message.setPreserveRecipients(true);

// Create And Attach Tags
ArrayList <String> tags = new ArrayList<String>();
tags.add("test");
message.setTags(tags);

/* There are more message details that can be added*/
try {
    MandrillMessageStatus[] messageStatusReports = mandrillApi
            .messages().send(message, false);

    // Iterate over responses
    for (MandrillMessageStatus statusReport: messageStatusReports) {
        _logger.info("Message Status Report: " + statusReport.getStatus());
    }
} catch (MandrillApiError e){
    _logger.error(e.getMandrillErrorAsJson(), e);
} catch (IOException e) {
    _logger.error(e.getMessage());
}

Stack Trace

java.lang.IllegalStateException: Unsupported cookie spec: default
    at org.apache.http.cookie.CookieSpecRegistry.getCookieSpec(CookieSpecRegistry.java:110)
    at org.apache.http.cookie.CookieSpecRegistry$1.create(CookieSpecRegistry.java:163)
    at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:157)
    at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:132)
    at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:166)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:878)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:84)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:109)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at com.microtripit.mandrillapp.lutung.model.MandrillRequestDispatcher.execute(MandrillRequestDispatcher.java:73)
    at com.microtripit.mandrillapp.lutung.controller.MandrillUtil.query(MandrillUtil.java:46)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:94)
    at com.microtripit.mandrillapp.lutung.controller.MandrillMessagesApi.send(MandrillMessagesApi.java:49)
    at <the file and line number where I called the aforementioned line>

TLSv1.0 and TLSv1.1 Deprecation - eff. May 31, 2018

Related to this link

Developer news

TLS 1.0 and 1.1 Deprecation

On May 31, 2018, we’ll be retiring support for TLS versions 1.0 and 1.1 on all MailChimp sites, including MailChimp’s API. This change improves the security of the data sent between you and MailChimp, whether you’re accessing MailChimp through a browser, communicating directly with our API, or using one of our integrations.

The technologies that help secure data are under continuous scrutiny by security researchers. Over time, many of these technologies fall below an acceptable level of security and data privacy. For instance, recent attacks against older SSL versions (POODLE) as well as vulnerabilities with TLS (LOGJAM) have shown that transport security is rapidly changing. MailChimp’s security team constantly monitors for issues like this; we previously removed support for SSL 3.0 and older ciphers as insecurities in those technologies became known.

Now, the PCI Security Standards Council-an organization that defines security practices for businesses that handle cardholder data—has updated their requirements to remove support for early TLS versions. This means that we must begin the process of retiring these technologies at MailChimp, too; a change that may cause issues if the systems and software that power API clients do not support TLS version 1.2.

We strongly encourage any developers who are using the MailChimp API to ensure that their software supports negotiating TLS 1.2 connections, and to coordinate with their system administrators to update software to take advantage of newer TLS versions. In addition, we recommend proactively switching over to TLS 1.2 when communicating with MailChimp’s API by modifying your API client software to enforce TLS 1.2 negotiation.

This won't effect users running Java 8 or newer (and some non-public release versions of 7 (I think > 1.7.0_80?) as they default to TLSv1.2.

Unexpected http status in response: 500 (Internal Server Error)

Hi,
I'm having some problems while trying to get info from subaccounts. The error is:

Unexpected http status in response: 500 (Internal Server Error)

Seems to happen when the subaccount does not exists

MandrillSubaccountInfo mandrillSubaccountInfo = mandrillApi.subaccounts().info(subaccountId);

subaccountId is 658

Also, when I try to send an email, and the subaccount doesn't exists, the error message shows:

{
"status": "error",
"name": "Unknown_Subaccount",
"message": "No subaccount exists with the id \u0027658\u0027",
"code": 12
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.