Search code examples
emailemail-headers

Is it possible to send email just to one person but in the TO field to add more email addresses(these users should not get an email)?


What I am trying to do is, sending an email to one person but I want to add more email addresses in the TO field and don't want that users to get the email. Is it possible to somehow configure this?


Solution

  • Yes, this is completely possible. SMTP doesn't actually use the headers for anything; the envelope recipient list controls who actually receives a message (though many user-visible email programs will simply copy the To:, Cc:, and Bcc: headers into the envelope on submission).

    Because you are not asking about any particular language, I won't post code which probably won't be useful to you anyway. In pseudocode, something like

    s = smtp.connect(server)
    s.ehlo()
    s.from(envelope.sender)
    for r in envelope.recipients:
        s.rcpt(r)
    s.data('''From: [email protected]
    To: [email protected]
    Subject: SMTP doesn't care
    
    By the time SMTP transmits the actual message,
    the recipient information has already been sent 
    separately.''')