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
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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.
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().
Try the settings at "site information", admin/config/system/site-information.