0

I want to change FROM Email id, when admin approved an user account.

Currently it is using admin email id. I want to use different email and my admin email id will remain same

Any Suggestions

3 Answers 3

2

I don't have enough reputation to comment, so I am expanding user1081275's answer -

The message id for the confirmation message you want to alter is 'status_activated'.

You can intercept outgoing mail with hook_mail_alter() in a custom module as described at https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_mail_alter/7

function mycustommodule_mail_alter(&$message) {
  if ($message['id'] == 'status_activated') {
    $message['from'] = "[email protected]";
  }
}

Per user.module, the ids for other messages defined by the User module in _user_mail_notify() are:

 *   - 'register_admin_created': Welcome message for user created by the admin.
 *   - 'register_no_approval_required': Welcome message when user
 *     self-registers.
 *   - 'register_pending_approval': Welcome message, user pending admin
 *     approval.
 *   - 'password_reset': Password recovery request.
 *   - 'status_activated': Account activated.
 *   - 'status_blocked': Account blocked.
 *   - 'cancel_confirm': Account cancellation request.
 *   - 'status_canceled': Account canceled.
1
  • don't have enough rep ? then have a '1 up' for expanding my answer as you bothered to find the right mail ID for the OP :) Commented Nov 16, 2014 at 20:14
0

You can intercept outgoing mail with hook_mail_alter() as described here

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_mail_alter/7

such as :

<?php

  function mycustommodule_mail_alter(&$message) {
    $message['from'] = "[email protected]";
  }

?>

NOTE : this changes it for all out going mail, you need to create a condition based on $message['id']

Also, as you really don't want that kind of thing hardcoded as it may change, you should create an admin settings form and save it to the database, returning the variable in the hook_mail_alter().

-2

Try the settings at "site information", admin/config/system/site-information.

2
  • it's admin email. i want to use different email id for sending emails Commented Nov 13, 2014 at 7:13
  • Your are asking to set the email "when admin approved an user account" The site information page specifically describes the 'Email address' field as the email address used in From headers on the site: "The From address in automated e-mails sent during registration and new password requests, and other notifications." - which answers your question directly. Please be more specific in your question - do you mean that you want to use a different email address only for for the new account confirmation messages?
    – calebtr
    Commented Nov 13, 2014 at 20:48

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.