2

I've been searching but didn't find much.

Is there any module or way to send emails with Drupal, but using different email accounts?

For example, I have a site which will have 3 different email accounts to send email. User A creates a node, the user will receive an email from the email account 1. User B takes an action, he or she will receive an email from the email account 2. Etc.

To sum up:

Is there any module to hold different email accounts in one drupal site and send email with them?

I've seen some modules to hold different email accounts for the users, but not for the site.

Thanks in advance.

2

Nice question you are right no module for that . but you can configure it by rules like
after saving node add action - sand e-mail userA on this add conditions according to your need like account type userA I think this is the possible way for that

  • Thanks for your answer. That could be a possible solution, but the problem is the account which sends the email, it must be different depending on the case. Changing the From field of the email without changing the email which truly sends the email will trigger the spam filters. – Salvador P. Jul 14 '16 at 10:38
  • well for this we have use token – Naveen Jul 14 '16 at 10:48
  • But token is different if userA is like seller type userB is buyer type so we can create token for email and then add action on it – Naveen Jul 14 '16 at 10:49
  • I'm afraid that creating a token to change the From field will not solve the problem, still we can't change the email account from where the messages are sent. – Salvador P. Jul 14 '16 at 12:31
1

You can use hook_mail_alter() for altering the from email address. You can check the message id accordingly and change the from address.

function MODULE_NAME_mail_alter(&$message) {
  if (isset($message['id']) && !empty($message['id'])) {
    if ($message['id'] == 'your condition') {
      $message['from'] = $message['headers']['From'] = 'your email address';
    }
  }
}
  • Thanks for your answer! Tried this and tried with the $message['headers']['Sender'] = $message['headers']['Return-Path'] fields too. The problem is that the email is rejected because of spoofing, we are sending always with the same account, and changing "on-the-fly" some of the fields. We send with email1@mail.com, but we need to send with email2@mail.com too. Unfortunately changing the headers does not solve the problem. – Salvador P. Jul 14 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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