4

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: person01@gmail.com;person02@gmail.com
Subject: Did You Both Receive It?

I hope you did

Instead of using

From: sendmail
To: person01@gmail.com
Cc: person02@gmail.com
Subject: Did You Both Receive It?

I hope you did
  • 1
    Separate them with commas, not semicolon. – Barmar May 14 '15 at 15:27
5

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: person01@gmail.com, person02@gmail.com
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: person01@gmail.com,
    person02@gmail.com
Subject: Did You Both Receive It?
  • +1 I suspected there was something cleaner, like this... I learnt something today! – John WH Smith May 15 '15 at 6:56
  • Sorry I never saw this until now, this did indeed solve my issue – TheLovelySausage Jul 11 '17 at 6:41
3

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: person01@gmail.com
Cc: person02@gmail.com
Subject: Did You Both Receive It?

I hope you did

... you could send:

From: sendmail
To: person01@gmail.com
To: person02@gmail.com
Subject: Did You Both Receive It?

I hope you did

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

To person01 <person01@gmail.com>, person02 <person02@gmail.com>

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

To: person01@gmail.com
To: person02@gmail.com

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 "person01@gmail.com,person02@gmail.com" <<EOF
To: person01@gmail.com
To: person02@gmail.com
...

Your message.
EOF
  • 2
    Some servers allow multiple To: headers, but beware that this is not standard behavior: the RFC 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 May 15 '15 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.