1

What I need is :

I need to send transactional e-mails from two SMTP configurations.

All WooCommerce side of e-mails should send from [email protected]. Example: order summary, delivery status.

All WordPress user side of e-mails should send from [email protected]. Example: Forget password e-mail, account creation e-mail.

Note: All methods are working. I just want to send different e-mails from their respective purpose.

2
  • Are you really sending from two different domains i.e maydomain.com and mydomain.com? If it’s a typo you should update your question title, because you’re not trying to configure two SMTP servers, but rather two From addresses which is a lot simpler
    – Andy
    Commented Jul 2, 2019 at 19:41
  • @Andy that was a typo. Sorry about that. But this not about from addresses. Same domain but I have two SMTP servers (main smtp server and marketing smtp server. Marketing smtp server is optimized send bulk emails)
    – Varuna
    Commented Jul 5, 2019 at 10:08

1 Answer 1

1

Disclaimer: this is clumsy, someone might have a better suggestion. But here's one idea:

  1. Leave WordPress configured with your [email protected] settings.
  2. Set up Woo with the [email protected] address (WooCommerce -> Settings -> Emails -> From Address).
  3. Hook woocommerce_mail_callback with your own function that temporarily hooks phpmailer_init to change the SMTP configuration before calling wp_mail.

Or perhaps you can skip step 3 if your SMTP server can be configured to allow an alternate "from" address for authenticated users.

And just a heads up: WooCommerce supplies its own forgot password and new account emails, so you'd need to decide whether you want to return those to their WordPress defaults, or just change them as well in step 3.

1
  • 1
    +1 Thank you @Den Wich . I'm going to give a try on this idea.
    – Varuna
    Commented Jul 5, 2019 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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