Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
}else{
 //Set from email
  $phpmailer->SetFrom('services@example.com', 'Services Example.com');
}
share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.