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.

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

1 Answer 1

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

 
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.