I'm simply calling wp_mail in a gform_pre_submission Gravity Forms hook (fires just before the entry is saved to the DB):
Snippet of the code sending the email:
$subject = $from->display_name.' ('.$from->user_login.') replied to your "'.$item->post_title.'" post! ';
$message = $before."\r\n\r\n".$content."\r\n\r\n".$after;
$headers = array( 'From: Website Name ('.$from->user_login.') <email@example.com>', 'Reply-To: '.$from->user_email );
wp_mail( $to->user_email, $subject, $message, $headers );
Gravity Forms also uses wp_mail:
$is_success = wp_mail($to, $subject, $message, $headers, $attachments);
My email goes through the native wp_mail function with the Invalid API key error - though the key is valid and CURL is enabled... so it's a red herring -- the error messages around API key validation could be more descriptive (e.g. a missing key is technically invalid, bit "API Key Missing" would be more useful, being unable to verify a key does not make it invalid, but unverifiable).
A contact form response sent by Gravity Forms... goes through Mandrill with no API error.
The "unable to resolve" error is from me dumping the $response in
Mandrill::request right after it's returned (or not in this case -- it appears to be a CURL error).
Hence why I'm baffled - if it's all going through the Mandril override of wp_mail - why the inconsistent behavior? Is it possible there are 2 code paths there? I worked my way all the way down to the
Mandrill::http_request and it all seems to be the same, but of course that would mean it's external to the code -- but that should mean that contact form responses fail to use Mandrill sometimes (they never do).
I tried using
wpMandrill::mail directly in my code but received the same errors, so the issue is deeper than the wp_mail wrapper code.