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);
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.