Installed Mandrill module, signed up for free account, and all looked fine.
When mandrill module configured for "test" mode, the response if positive and all looks fine.
But when configured to be "on", and a form processed, the following error is thrown:

Mandrill_Exception: - in Mandrill->__construct() (line 31 .....

And i get a messed up layout on page.
I have disabled the module for now - any ideas where to look first?

Comments

lsolesen’s picture

@mudsurfer Do you still have this issue with beta1 - otherwise you can close it?

mudsurfer’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.0-beta1

Updated module to 7.x-1.0-beta1

when the module configuration "Mandrill Mail interface status" is set to "on", and I try to send an email/webform/contactform, it gives me a whitescreen and this error:

Error
Error message
Mandrill_Exception: - in Mandrill->__construct() (line 31 of /home/clients/websites/[user]/public_html/[site]/sites/all/modules/mandrill/mandrill.class.php).
The website encountered an unexpected error. Please try again later.

When I set the module configuration "Mandrill Mail interface status" to "off", the site resumes operation normally, and I can send via php sendmail.

So, sorry, the changes to beta1 did not fix anything for me.
Cheers

Anonymous’s picture

I overcame this problem by extending the CURL timeouts. Sorry I don't have a patch to upload, but this is the patch:

diff --git a/mandrill.class.php b/mandrill.class.php
index c349609..5f8b49c 100644
--- a/mandrill.class.php
+++ b/mandrill.class.php
@@ -376,7 +378,8 @@ class Mandrill {
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
     curl_setopt($ch, CURLOPT_HEADER, FALSE);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60 * 60 * 1000);
+    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
+    curl_setopt($ch, CURLOPT_TIMEOUT, 8);
 
     $response = curl_exec($ch);
     $info = curl_getinfo($ch);

The timeout constants are in seconds. There's another option to set up millisecond timeouts, but it's a bit tricker and probably this project should stick with whole second timeouts.

lsolesen’s picture

This does not make it possible for me to send test mails if those issues are related.

rowbotony’s picture

I'm also still having this issue with -beta1 - same procedure: install, enable, add my api key, verify DKIM and SPF, turn ON, then send a test message resulting in Error:

Mandrill_Exception: - in Mandrill->__construct() (line 31 of /var/www/htdocs/sites/all/modules/mandrill/mandrill.class.php).

I'm on AWS EC2, should I change to the -dev branch?

nafmarcus’s picture

The two-line code change above did not do fix the problem for me either and we would very much like to move to MailChimp for mail relay.

levelos’s picture

The operation timeout is already set in Mandrill::http_request().

    if (!ini_get('safe_mode')) {
      set_time_limit($this->timeout);
    }

We could bump up the connection timeout as @bangpound suggets. But seems if just the connection is timing out, there are other issues? We could also consider using drupal_http_request() instead of curl.

dabblela’s picture

Also having this issue, and it seems to be something on a system level, as it worked well on my local development environment but failed when moved to production.

Also worth noting that Mandrill shows nothing in the API Logs.

dabblela’s picture

Switching from curl to drupal_http_request() fixed this issue for me, but curl would be ideal as I've found it to be much faster.

fenstrat’s picture

@manatwo Care to share how you used drupal_http_request()? I'm having exactly the same issue you had, was working fine locally, but is failing on production.

dabblela’s picture

StatusFileSize
new1.72 KB

This a real basic patch; I'm almost positive it needs work to be committed but I'm using it in production for now.

fenstrat’s picture

Title: Error when made "live" » Avoid curl errors by using drupal_http_request() instead
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new2.31 KB

Thanks @manatwo. That worked a treat for me, sending on production and locally finally works.

I've made a few changes in the attached. I've taken the knife to http_request() as after what you'd done all it was doing was calling set_time_limit() so I've made $this->timeout a param to drupal_http_request() and gotten rid of http_request() alltogether. Also changed json_encode() to drupal_json_encode().

levelos’s picture

Does anyone have any details, E.g., server messages, about the curl errors? From everything I understand, curl is a better overall choice, unless, of course, it doesn't work ;)

fenstrat’s picture

@levelos I've just checked apache error logs, there's nothing there. It doesn't seem to get that far, the error is logged in watchdog as Error sending email from from@example.com to to@example.com. 500: You must specify a key value - Array. Though I've also seen the Mandrill_Exception error noted here in #0 though I can't seem to reproduce that now. One thing is certain from my end, when curl is removed as per #12 all these errors disapear and sending works as it should.

lsolesen’s picture

@levelos. I cannot find any server errors. I am on an ubuntu server on Linode where everything has been installed from the repositories. Getting the same errors as @fenstrat.

lsolesen’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that the patch in #12 fixes the problem for me also.

jlab’s picture

The patch in #12 has worked quite well for me as well.

pal4life’s picture

Category: bug » support

Hi,
That patch did take away the Api -key error message but I have still not been successful in receiving a test email. Now there is no more anything in the drupal logs. Although Mandrill logs show this

Jul 5, 2012 8:01 pm /messages/send.json
{"message": null, "key": "xxxxxxkeyidhere"}
{}

Not sure why the message is null. I will open a separate ticket for this.
Thanks.

pal4life’s picture

Pardon me seems like my comment opened this ticket again.

lsolesen’s picture

@pal4life. You should open a new issue.

pal4life’s picture

Yes I will, please close this ticket, I do not think I can close it.

fenstrat’s picture

Category: support » bug

@pal4life This issue is not closed, it is RTBC which means it is ready and waiting to be committed.

gabriele.genta’s picture

I had the same issue on Amazon EC2, patch #12 solves it. Thanks!

fenstrat’s picture

Another report that the patch here in #12 solves this issue #1734936-2: Unable to send email when turned on.

basvredeling’s picture

#12 works fine, hope this gets committed soon.

levelos’s picture

Status: Reviewed & tested by the community » Fixed

Sorry for the delay gang, committed.

fenstrat’s picture

Great to see this committed and the new 1.1 release. Thanks @levelos.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit ef32a72 on 7.x-1.x, 6.x-1.x, 7.x-2.x by levelos:
    #1594244: Avoid curl errors by using drupal_http_request() instead.