Hook into wordpress send email function

//********************************************
//********************************************
//********** FILTER OUTGOING EMAILS **********
//********************************************
//********************************************
//Any plugin or theme sending email is likely to be using wp_mail() to do it
add_filter( 'wp_mail', 'filter_wp_mail' );
function filter_wp_mail( $args )
{
  //$args Fields:
  //  $args['to']
  //  $args['subject']
  //  $args['message']
  //  $args['headers']
  //  $args['attachments']
  
  //----- FILTER OUT EMAILS SENT BY DIVI CONTACT FORM -----
	//if (strpos($args['subject'], 'New Message From') !== False)
  if (strpos($args['to'], '[email protected]') !== False)     //<We set the email address to this so we can trap them here
	{
			$args['to'] = "";      //Remove the 'to' field to stop the email being able to be sent
	}
  
  return ($args);
}
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published.