2

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
tabassum
  • 21
  • 1
  • 2

3 Answers3

5

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.)

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
1

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.

JW8
  • 1,496
  • 5
  • 21
  • 36
0

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).

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40