function mimemail_address in Mime Mail 7
Same name and namespace in other branches
- 5 mimemail.module \mimemail_address()
- 6 mimemail.inc \mimemail_address()
Formats an address string.
@todo Could use some enhancement and stress testing.
Parameters
mixed $address: A user object, a text email address or an array containing name, mail.
bool $simplify: Determines if the address needs to be simplified. Defaults to FALSE.
Return value
string A formatted address string or FALSE.
5 calls to mimemail_address()
- mimemail_example_form_submit in modules/
mimemail_example/ mimemail_example.module - Form submission logic for the email contact form.
- mimemail_headers in ./
mimemail.inc - Gives useful defaults for standard email headers.
- mimemail_prepare_message in ./
mimemail.module - Prepares the message for sending.
- rules_action_mimemail in ./
mimemail.rules.inc - Action Implementation: Send HTML mail.
- rules_action_mimemail_to_users_of_role in ./
mimemail.rules.inc - Action: Send HTML mail to all users of a specific role group(s).
File
- ./
mimemail.inc, line 545 - Common mail functions for sending e-mail. Originally written by Gerhard.
Code
function mimemail_address($address, $simplify = FALSE) {
if (is_array($address)) {
// It's an array containing 'mail' and/or 'name'.
if (isset($address['mail'])) {
if (empty($address['name']) || $simplify) {
return $address['mail'];
}
else {
return '"' . addslashes(mime_header_encode($address['name'])) . '" <' . $address['mail'] . '>';
}
}
// It's an array of address items.
$addresses = array();
foreach ($address as $a) {
$addresses[] = mimemail_address($a);
}
return $addresses;
}
// It's a user object.
if (is_object($address) && isset($address->mail)) {
if (empty($address->name) || $simplify) {
return $address->mail;
}
else {
return '"' . addslashes(mime_header_encode($address->name)) . '" <' . $address->mail . '>';
}
}
// It's formatted or unformatted string.
// @todo: shouldn't assume it's valid - should try to re-parse
if (is_string($address)) {
return $address;
}
return FALSE;
}