The system action send-mail provides you a configurable form, setting mail text, subject, and recipient.

In the recipient field you can either set a static email value OR you can set a token with ':mail' in the ending.

I'd like to use the email_field with multiple values for the recipient field.
Now I'm stuck. Should I write a module with a custom action, or wouldn't it be nice if the email field would provide a token format ':mail', where the output is just the email, and with multiple values: 'emai1, email2, email3...'

The token format output would be nice. But if there are more elegant solutions, please inform. thanks.

Comments

mxh’s picture

regarding the problem of the send email action, see http://drupal.org/node/284036#comment-5691862 for further information.

If you are using email field module, which brings a new cck field for email adresses, and you'd like to use this field (also with multiple values) for recipients, you should implement (per own module or patch) the hook hook_field_info_alter() like in following snippet:

<?php
/**
 * Implements hook_field_info_alter().
 */
function email_send_field_info_alter(&$info) {
  
  if(!empty($info['email'])) {
	$info['email'] += array('default_token_formatter' => 'email_plain',);
  }
  
}
?>

... so the default token output is raw email text.

This is just a quick solution for those who are having similar problem. Modifying system module is usually a bad idea.
Better would be a token for email fields, like [node:YOUEMAILFIELD:mail] so no modification of the system module would be needed and you could use it for recipient field in system's send-mail action.

Unfortunately, i don't know how to implement this, anyone knows?

Ivan Simonov’s picture

Issue summary: View changes

'Email Field' module default formatter is 'Default email link'.
This approach incompatible with 'Field default token' module.
Instead of using plain email it capture mailto link: <a href="mailto:email@test.com">email@test.com</a>
So it is impossible to use value of one 'Email Field' as default value for enother 'Email Field'.

Best solution to change default formatter from 'email_default' to 'email_plain' in code.

Ivan Simonov’s picture

Version: 7.x-1.0 » 7.x-1.3
StatusFileSize
new447 bytes

Patch for this issue.

mxh’s picture

Status: Active » Needs review

Nice mate, thanks. But maybe this can break a lot of site installations, because people can let the default formatter be as it is and rely on it that it's automatically rendering as a link.

For contributing, I think an update hook would be neccessary which converts the formatters set up as default explicitly to a link formatter. I cant test this by myself at the moment so I set the status to needs review.

fonant’s picture

I'd rather see different sub-tokens like:

[field-email:mail] = plain email address
[field-email:link] = HTML format link (with mailto: href).

There seems to be unfinished code, commented out, that might supply:

[field-email:raw]
[field-email:formatted]

which do the same thing.

jerry’s picture

Patch in #3 is working fine for me. The commented-out code referenced in #5 isn't actually working, which probably explains why it's commented-out.