Hi,

Is it possible to set the 'reply to' email address as the active user's email address?

I've got a 'staff' user role where all user emails are from the same domain as the global address but need to be able to initiative personal dialogs between my staff and the recipients via the bulk emails sent from views_send

Comments

hansfn’s picture

Status: Active » Closed (fixed)

My normal reply to requests like this one, is to use hook_form_alter:


/**
  * Implements hook_form_alter().
  */
function mymodule_alter_form(&$form, &$form_state, $form_id) {
    global $user;
    if (strpos($form_id, 'views_form') === 0) {
        if (isset($form['from']['views_send_from_mail'])) {
            // For staff members, use their email address as sender address (and hide the field).
            if (in_array('staff', $user->roles)) {
                $form['from']['views_send_from_mail']['#default_value'] = $user->mail;
                $form['from']['views_send_from_mail']['#disabled'] = TRUE;
            }
        }
    }
}

I hope you have created a custom module earlier so you know how to enable the code above.

Let me know it works - the code above is untested.