sending email using “bcc” without “to” in java application

允我心安 提交于 2019-12-20 03:18:14

问题


I have read all the reference in stackoverflow. However, nothing matches in our goal. How can i use bcc in sendmail method in java?


回答1:


According to the RFC for SMTP, RFC 2821 (link), it is not possible to send an email message without a To: header. (You cannot send an RCPT command without it, see section 3.3.)




回答2:


As Dietrich mentions, that's not possible with the RFC. If the primary goal is to send to the bcc target email addresses, you could provide a dummy to email address (such as your own email address or a reply-to email), which would fulfill that technicality while still allowing you to send the email to the desired bcc targets.




回答3:


msg.addRecipient(Message.RecipientType.BCC, new InternetAddress("joe@example.com"));

By default, JavaMail collects all the recipients specified on the Message object, including Bcc recipients, and uses them in the RCPT command to the SMTP server. The Bcc recipients won't show up in the message headers, however (which is the whole point of Bcc).



来源:https://stackoverflow.com/questions/8407145/sending-email-using-bcc-without-to-in-java-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!