WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to check an email from email via WordPress before an email is sent?

I'm working on a phpmailer plugin to send WordPress email via Amazon SES (which requires all emails to be verified). I'm using WordPress multisite and would like to set a different verified email per site.

So I would like to know if it is possible to get the variable that contains the from email to accomplish something similar to the following.

if(fromEmailVaribale == 'info@example.com'){
 //Set from email
  $phpmailer->SetFrom('info@example.com', 'Example.com');
 //Set from email
  $phpmailer->SetFrom('services@example.com', 'Services Example.com');
share|improve this question

In wp_mail() there are filters to adjust from address:

// Plugin authors can override the potentially troublesome default
$phpmailer->From     = apply_filters( 'wp_mail_from'     , $from_email );
$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name  );

However they don't seem convenient for your needs because they don't provide access to mailer object at the same time.

You are probably better of using action hook further down

do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );

to check what $From field in it holds and adjust if necessary.

share|improve this answer
Thanks for responding I'm not too familiar on how to use the do_action_ref_array can you please explain it a bit further thanks – Oudin Jun 15 '13 at 15:31
@Oudin do you know how to work with action hooks in general? It's just slightly different form of do_action(), so use add_action() and get mailer object passed as argument to your callback. – Rarst Jun 15 '13 at 18:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.