Jump to:
| Project: | Webform |
| Version: | 7.x-3.9 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I would like to see the [site:mail] as an available token.
Why?
Because I want to autopopulate the "from" and "to" email address fields.
A little more...
I'm using Domain Access module, which allows you to share content across multiple domains... So instead of having to create separate forms for each domain, I would like to be able to use the same form, and just autopopulate the data from the active domain.... pretty neat huh?
So in other words,
I have around 20 webforms that I want to share across multiple domains (200+), and I don't want to have to recreate every 20 forms for each domain... I just want to use the current (active) domain's email address and site name (which webform already has a token for)
Thank you and have a great day.
Comments
#1
I also use the Domain Access module and sought a global token to populate the From address: field by domain at /admin/settings/webform. Although it is not well documented and somewhat counter-intuitive, the functionality already exists through the following:
%get[email]This is equivalent to $site_email (AND/OR the email address set at admin/settings/site-information AND/OR the DA domain configuration at /admin/build/domain/conf/[domain_id]) and not related to the submitted email %value field.
#2
Yeah I figured it out. Just duplicate the current "site_name" instances, and replace with "site_email" .
This should definitely be in the module if "site_name" exists--i see no reason why it's not.
#3
That doesn't work correctly for me. When I use %site_email, the From line in the email reads:
info@donotreply.com on behalf of sitename.com <Full site title_email>
As you can see, the first part displays the site owner email correctly. The angle brackets on the right side should contain the exact same thing, but somehow it behaves as if %site_name is inserted here (because it only reads the %site portion of the token.) The tail end is left raw as:
_email
#4
@kalanh: What you're describing is a result of server configuration.
See for more information: #461324: In E-Mails generated by Webform appears the Website E-Mail address as "Sender" and use this module to avoid the problem: http://drupal.org/project/webform_reply_to
#5
webform.module
// Setup default token replacements.$domainsource = str_replace('www.','', $_SERVER['SERVER_NAME']);
if (!isset($replacements)) {
$replacements['unsafe'] = array();
$replacements['safe']['%site'] = variable_get('site_name', 'drupal');
$replacements['safe']['%mail'] = variable_get('site_mail', 'drupal');
$replacements['safe']['%domainsource'] = $domainsource;
$replacements['safe']['%date'] = format_date(REQUEST_TIME, 'large');
}
/*** Retreive a Drupal variable with the appropriate default value.
*/
function webform_variable_get($variable) {
switch ($variable) {
case 'webform_allowed_tags':
$result = variable_get('webform_allowed_tags', array('a', 'em', 'strong', 'code', 'img'));
break;
case 'webform_default_from_name':
$result = variable_get('webform_default_from_name', variable_get('site_name', ''));
break;
case 'webform_default_from_address':
$result = variable_get('webform_default_from_address', variable_get('site_mail', ini_get('sendmail_from')));
break;
case 'webform_default_subject':
$result = variable_get('webform_default_subject', t('Form submission from: %title'));
break;
case 'webform_node_types':
$result = variable_get('webform_node_types', array('webform'));
break;
case 'webform_node_types_primary':
$result = variable_get('webform_node_types_primary', array('webform'));
break;
}
return $result;
}
function theme_webform_token_help($variables) {
$groups = $variables['groups'];
$groups = empty($groups) ? array('basic', 'node', 'special') : $groups;
static $tokens = array();
if (empty($tokens)) {
$domainsource = str_replace('www.','', $_SERVER['SERVER_NAME']);
$tokens['basic'] = array(
'title' => t('Basic tokens'),
'tokens' => array(
'%username' => t('The name of the user if logged in. Blank for anonymous users.'),
'%useremail' => t('The e-mail address of the user if logged in. Blank for anonymous users.'),
'%ip_address' => t('The IP address of the user.'),
'%site' => t('The name of the site (i.e. %site_name)', array('%site_name' => variable_get('site_name', ''))),
'%mail' => t('The site owner email (i.e. %mail)', array('%mail' => variable_get('site_mail', ''))),
'%domainsource' => t('The source site domain name(i.e. %domainsource)', array('%domainsource' => $domainsource)),
'%date' => t('The current date, formatted according to the site settings.'),
),
);
webform.admin.inc
$form['email']['webform_default_from_address'] = array('#type' => 'textfield',
'#title' => t('From address'),
'#default_value' => variable_get('webform_default_from_address', variable_get('site_mail', ini_get('sendmail_from'))),
'#description' => t('The default sender address for emailed webform results; often the e-mail address of the maintainer of your forms.'),
);
then create the following in your webform:
form component
site_email hidden %mail
e-mails
email to address: component : site_email
The above is not the clearest instructions, but everything you need is there (i'm way too busy to even put the above together.... it works fine for me, using with 200 domains.
#6
@duntuk (and others): I'd highly discourage you from modifying Webform's source code. Doing so will make upgrading to new releases that either fix bugs or add new features tremendously more difficult.
#7
Thanks for the Webform Reply To suggestion. It solves the problem of email clients forming messages with an incorrect "To:" field. I understand now that the "From address" field in Webform Settings applies only the the message header.
Unfortunately, it is not an automated solution for multisite setups (Domain Access) like duntuk and myself. With over 200 sites each to administer, each site would be left with "Default: No reply-to address."
In the end, I convinced my superior that the reply-to address was not really necessary for our use case. An email from a Webform submission is more of an abstract email. There's no need to reply to the server or even the server admin. The information contained in the submission itself may or may not include a real email address depending on configuration. A simple global "Do not reply" string actually made the most for our end users, who often thought a message from their own email address might be spam.
#8
As for the request for a [site:mail] token, let's merge this with the progressing patch at #1001798: Rewrite token replacement system to use D7 tokens.