Reputation: 1488
I am using mailto
link to populate bcc
of users default email program.
$mem_email=" ";
$sql="SELECT email_address FROM employee";
$contacts = $db->query($sql);
while($contact = $db->fetchByAssoc($contacts))
{
if($contact['email_address']!="" && $contact['email_address']!=NULL)
{
$mem_email.=$contact['email_address'].", ";
}
}
header("Location: mailto:?bcc={$mem_email}");
What is the best separator to separate multiple emails in bcc field: ,
or ;
?
In my case, I am using ,
.
Upvotes: 44
Views: 43849
Reputation: 339856
The separator should be a comma (,
) and there should not be a space.
See RFC 6068.
Upvotes: 55
Reputation: 20911
TLDR Answer: Use a ,
without spaces to separate e-mail addresses.
RFC6068: The 'mailto' URI Scheme (published October, 2010) is only a proposed standard, and it is not an accepted, Internet standard. It also doesn't discuss comma-separation.
Sender
field (for security reasons).,
, so an ideal regex for splitting would be /\s*,\s*/
.;
. This is because the X.400/X.500 specification that treats semicolons as a valid name-separator (see RFC1485, published July, 1993). Going forward, using ,
is recommended.To quote the original proposed standard, RFC2822: Internet Message Format, published April, 2001...
3.6.3. Destination address fields
The destination fields of a message consist of three possible fields, each of the same form: The field name, which is either "To", "Cc", or "Bcc", followed by a comma-separated list of one or more addresses (either mailbox or group syntax).
to = "To:" address-list CRLF cc = "Cc:" address-list CRLF bcc = "Bcc:" [address-list / CFWS] CRLF
This proposed standard was accepted as a draft standard in October, 2008, with RFC5322: Internet Message Format. I would quote the text there, but they decided to keep it exactly as it is. An update was proposed in March, 2013, with RFC6854: Update to Internet Message Format to Allow Group Syntax...: you shouldn't be allowing comma-separated values in the Sender
field, because then it's uncertain who really triggered sending the e-mail. To quote this RFC, RFC6854...
2.1. Replacement of RFC 5322, Section 3.6.2. Originator Fields
...The from field and the sender field SHOULD NOT use group syntax; rather, the from field SHOULD use only the mailbox-list syntax and the sender field SHOULD use only mailbox syntax (see RFC 6854, Section 3). If the sender field uses group syntax, the group MUST NOT contain more than one mailbox.
Upvotes: 3
Reputation: 14383
Here's a late caveat in case anybody needs it:
Even though RFC explicitly recommends a comma, Microsoft Outlook will use the "list separator character" defined in the regional settings. Your mailto links may not work correctly for your Windows + Outlook users whose systems are configured with a different list separator such as semicolons. Outlook will simply refuse to split the e-mail addresses with commas.
Just something to keep in mind.
Upvotes: 16
Reputation: 154
Use following code,
implode(',', $contacts);
above code will give comma separated emails.
Upvotes: 1