6

Hello everyone I was wondering if it's possible to use sendmail in a way that I can string multiple email addresses in the To: as such

From: sendmail
To: [email protected];[email protected]
Subject: Did You Both Receive It?

I hope you did

Instead of using

From: sendmail
To: [email protected]
Cc: [email protected]
Subject: Did You Both Receive It?

I hope you did
TheLovelySausage
  • 4,183
  • 9
  • 30
  • 49

2 Answers2

7

To put multiple addresses on the To: or Cc: or Bcc: line, separate them by a comma (plus optional spaces). There are mail readers that allow typing a semicolon to separate addresses and show addresses separated by semicolons, but this is not standard syntax.

From: sendmail
To: [email protected], [email protected]
Subject: Did You Both Receive It?

You can split the header onto multiple lines after the comma (and at some other places in the address, but this is trickier). The continuation line must start with at least one space or tab.

From: sendmail
To: [email protected],
    [email protected]
Subject: Did You Both Receive It?
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
5

You can use the To: header several times. I was a little skeptical about it, but I just tried it on a SMTP server, and it accepted it.

So, instead of sending...

From: sendmail
To: [email protected]
Cc: [email protected]
Subject: Did You Both Receive It?

I hope you did

... you could send:

From: sendmail
To: [email protected]
To: [email protected]
Subject: Did You Both Receive It?

I hope you did

In my client (Thunderbird), the recipients appear together, as:

To person01 <[email protected]>, person02 <[email protected]>

and the source remains intact (the To:s were not transformed on the way) :

To: [email protected]
To: [email protected]

Now, since the SMTP server allowed me to send two RCPT TO: messages, I'm assuming sendmail would be able to do this as well. Probably something like...

$ sendmail "[email protected],[email protected]" <<EOF
To: [email protected]
To: [email protected]
...

Your message.
EOF
John WH Smith
  • 15,500
  • 6
  • 51
  • 62
  • 3
    Some servers allow multiple `To:` headers, but beware that this is not standard behavior: the [RFC](https://tools.ietf.org/html/rfc5322) states that `To:` and `Cc:` can occur at most once. I suspect that there are MTAs that ignore all but the first or last `To:` line. – Gilles 'SO- stop being evil' May 15 '15 at 02:08