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

How to check if an email was sent from or originated from a specific plugin.

E.g. I have an SMTP plugin which sends all mail via SMTP however I would like to determine in the SMTP plugin. If an email originated from plugin x then the SMTP plugin would assign different "from" and "reply-to" headers as oppose to if it originated from plugin y

share|improve this question
I don't fully understand - you have 2 SMTP plugins sending two different emails? – Nicholas Pickering Feb 22 '13 at 6:11
No. It's one smtp plugin which captures all WordPress mail and sends them via smtp. However the "from" and "reply-to" is hard coded in the smtp plugin. which causes all emails to have the same hard coded "reply-to" – Oudin Feb 22 '13 at 15:53

I don't think there is any way of knowing something x is orginated from some plugin x. If both plugins do not offer any administrative controls for setting from and reply to address, you might want to hack the plugin files code sending email. if it is using wp_mail function to send email, you can pass your headers as below before wp_mail,

$headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
wp_mail('test@test.com', 'subject', 'message', $headers);

or you can have filter for from address

add_filter( 'wp_mail_from', 'my_mail_from' );
function my_mail_from( $email )
    return 'myemail@mydomain.com';
wp_mail('test@test.com', 'subject', 'message');
remove_filter( 'wp_mail_from', 'my_mail_from' );
share|improve this answer

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.