Email multiple recipients without revealing other recipients

前端 未结 8 1910
庸人自扰
庸人自扰 2020-12-24 08:20

I\'m using javamail to send emails to a list of recipients, but don\'t want them to be able to see who else received the email. I also don\'t want to send it using BCC sinc

相关标签:
8条回答
  • 2020-12-24 08:22

    The SMTP protocol doesn't care who's listed in the message and the recipients specified on the RCPT TO command are only used to figure out who to transport the message to. There's nothing stopping you from building the RFC822 message with the To header as you've defined above and then writing a custom SMTP client that send your particular message out but with a different set of recipients. And just because you can send the message doesn't mean a spam filter along the way is going to notice the wonky recipient headers and block the message.

    In my experience, JavaMail's SMTP client is really good at sending basic messages without any of the mail tricks you often seen used by mailing list providers and spammers. Those companies spend a lot of effort to make sure they can send messages the way they want but they also are in a constant fight to make sure they're messages are treated as legit email.

    Short answer: I'd resort to BCC and if this is for marketing purposes, consider using a company that specializes in this kind of thing.

    0 讨论(0)
  • 2020-12-24 08:23

    No, there isn't a way to do this with email.

    You have to explicitly build and send an email iterating by each of your recipients, one of them as the sole member of your addressTo array.

    0 讨论(0)
  • 2020-12-24 08:23

    Actually, we don't have to manually create InternetAddress objects for Multi Recepients. InternetAddress api provides a parse() method to do this for us. Sample code for this is as below,

    msg.setRecipients(Message.RecipientType.TO,  InternetAddress.parse(toAddress));
    

    Here parse method creates multiple InternetAddress objects if toAddress contains multiple email addresses seperated by ,(comma).

    Check for below API for more details.

    http://docs.oracle.com/javaee/6/api/javax/mail/internet/InternetAddress.html#parse(java.lang.String)

    Happy Coding. :)

    0 讨论(0)
  • 2020-12-24 08:24

    as Message.RecipientType you should use Message.RecipientType.BCC to not showing the every address to every recipient

    Google Keywords: Java Mail BCC

    0 讨论(0)
  • 2020-12-24 08:38

    You can do this by setting the code as below

    message.setRecipients(Message.RecipientType.BCC, toAddrs);
    

    instead of

    message.setRecipients(Message.RecipientType.TO, toAddrs);
    
    0 讨论(0)
  • 2020-12-24 08:42

    Why are you concerned about the recipient not seeing his own address? He already knows his his own address, so why is it an issue? BCC was designed to handle exactly the problem you describe. It's been around for decades & sounds like a perfect fit.

    0 讨论(0)
提交回复
热议问题