Title: proper address format
Last modified: November 30, 2018

---

# proper address format

 *  [Steve Taylor](https://wordpress.org/support/users/gyrus/)
 * (@gyrus)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/proper-address-format/)
 * I’ve found that the plugin doesn’t deal with address formatting properly. Since
   it overrides wp_mail() you can only pass address in as an array or comma-separated
   string. But if the format includes a name, e.g. ‘”User Name” <user@test.com>’,
   this will be passed straight through to the Mandrill API and fail.
 * To fix this, I’m using the following filter:
 *     ```
       add_filter( 'mandrill_payload', 'my_mandrill_payload', PHP_INT_MAX );
       function my_mandrill_payload( $payload ) {
   
       	// Break out quoted names to proper format for Mandrill
       	$new_to = array();
       	foreach ( $payload[ 'to' ] as $to_address ) :
   
       		// Is there a name?
       		if ( preg_match( '/([^<]*)<([^>]+)>/', $to_address['email'], $matches ) === 1 ) :
   
       			// Include name
       			$new_to[] = array(
       				'email' => trim( $matches[ 2 ] ),
       				'name'  => trim( trim( $matches[ 1 ] ), '"\'' ),
       				'type'  => 'to',
       			);
   
       		else :
   
       			// No name
       			$new_to[] = array(
       				'email' => $to_address['email'],
       				'type'  => 'to',
       			);
   
       		endif;
   
       	endforeach;
   
       	// Pass 'to' through
       	$payload['to'] = $new_to;
   
       	return $payload;
   
       }
       ```
   
 * What with this and other things (we’d really like to tidy up the large amount
   of PHP notice/warning errors, and handling of HTML vs. text could be slicker),
   we’d love to contribute to the plugin. However, I’m rusty with SVN, and work 
   much better with Git. Any chance dev code could be cloned and worked with on 
   GitHub?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Matt Miller](https://wordpress.org/support/users/millermedianow/)
 * (@millermedianow)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/proper-address-format/#post-11212097)
 * Hi there, we’d love to have you contribute to the plugin. We have a GitHub repository
   here where you can contribute:
 * [https://github.com/Miller-Media/send-emails-with-mandrill](https://github.com/Miller-Media/send-emails-with-mandrill)
 * I will leave this open but feel free to fork the repository and submit a pull
   request and we will review and get back to you. Thanks for your help!

Viewing 1 replies (of 1 total)

The topic ‘proper address format’ is closed to new replies.

 * ![](https://ps.w.org/send-emails-with-mandrill/assets/icon-256x256.png?rev=1920659)
 * [Send Emails with Mandrill](https://wordpress.org/plugins/send-emails-with-mandrill/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/send-emails-with-mandrill/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/send-emails-with-mandrill/)
 * [Active Topics](https://wordpress.org/support/plugin/send-emails-with-mandrill/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/send-emails-with-mandrill/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/send-emails-with-mandrill/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Matt Miller](https://wordpress.org/support/users/millermedianow/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/proper-address-format/#post-11212097)
 * Status: not resolved