Support

Home Forums Event Espresso Premium Error When Sending Notices But It Sent

Error When Sending Notices But It Sent

Posted: January 12, 2016 at 1:25 pm

Viewing 7 reply threads


b2995

January 12, 2016 at 1:25 pm

Hey Guys!

Why would I be getting a “Something went wrong and the message for this registration was NOT resent” error message but the emails were sent?

I set up Mandrill and all is testing well. I have the latest version of EE4 and I’m on a recommended hosting account.

Thank you


Tony

  • Support Staff

January 12, 2016 at 1:33 pm

Hi there,

This is likely caused by the Mandrill plugin not handling ‘Formatted’ email address correctly.

We have a fix for this here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/third-party-integration/de_ee_fix_mandrill.php

You can add that to your themes functions.php file or a Site Specific Plugin.


b2995

January 12, 2016 at 1:46 pm

Am I supposed to add that entire code to functions.php? If so it’s spitting out an error for line 1

<?php 
if ( ! defined('ABSPATH')) exit('No direct script access allowed');
/*
 * You can take this and install it as a WordPress Plugin and activate
 */
/*
  Plugin Name:		Fix wpMandrill.
  Plugin URI:  		https://gist.github.com/nerrad/2686a4be42da2ca76047
  Description: 		wpMandrill doesn't setup formatted to field addresses to work correctly with the mandrill api.  This fixes that.
  Version: 			1.0.0
  Author: 			Darren Ethier
  Author URI: 	http://roughtsmootheng.in
  License: 			GPLv2
  Copyright 			(c) 2008-2014 Event Espresso  All Rights Reserved.
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
function de_ee_fix_wpmandrill_to( $payload ) {
	$new_to = array();
	if ( isset( $payload['to'] ) ) {
		foreach ( $payload['to'] as $to )  {
			$new_to[] = de_ee_maybe_parse_formatted_email( $to );
		}
	} else {
		return $payload;
	}
	$payload['to'] = $new_to;
	return $payload;
}
add_filter( 'mandrill_payload', 'de_ee_fix_wpmandrill_to' );
/**
 * This takes an incoming email address from mandrill and if this is a formatted to address we break it into the component
 * parts.
 *
 * @see wp_mail() the native wp_mail() function has this code.
 *
 * @param array $to  process to address by wpMandrill plugin
 *
 * @return array new processed array.
 */
function de_ee_maybe_parse_formatted_email( $to ) {
	$to_address = isset( $to['email'] ) ? $to['email'] : null;
	if ( empty( $to_address ) ) return $to; //get out because wpMandrill has likely started doing something strange.
	if( preg_match( '/(.*)<(.+)>/', $to_address, $matches ) ) {
		if ( count( $matches ) == 3 ) {
			$to['name'] = $matches[1];
			$to['email'] = $matches[2];
		}
	}
	return $to;
}


Tony

  • Support Staff

January 12, 2016 at 2:04 pm

Ah, my apologies, its been wrapped within a plugin.

You can add that as a standard plugin and it will show in Dashboard -> Plugins.

Activate it and then retest.


b2995

January 12, 2016 at 3:40 pm

I took the above
Saved it in a txt file as de_ee_fix_mandrill.php
Zipped it
Uploaded it as a Plugin
Activated it

Same message…
An error has occurred:
Something went wrong and the message for this registration was NOT resen

Let me know if I did that incorrectly.


Lorenzo Orlando Caum

  • Support Staff

January 12, 2016 at 3:51 pm

Hi, those steps sound correct. Do you see the plugin mentioned earlier activated like this?

http://cl.ly/1k0u3R3m1S0S


Lorenzo


b2995

January 21, 2016 at 10:37 am

Hey Lorenzo! It seems to be working now, for whatever reason. Thank you! 😉


Lorenzo Orlando Caum

  • Support Staff

January 21, 2016 at 10:44 am

Thanks for letting us know. I’ll update your support post to resolved.

Enjoy your weekend!


Lorenzo

Viewing 7 reply threads

The support post ‘Error When Sending Notices But It Sent’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso