0

I am using IBM websphere commerce setup.

Here are the code details :

((JCAEmailConnection) this.getConnection())
                            .getManagedConnection().getTransport().sendMessage(
                                    message, message.getAllRecipients());

I am sure that the code gets executed to this point. This line calls sendMessage function of com.sun.mail.smtp.SMTPTransport

getAllRecipients method is called from javax.mail.internet.MimeMessage

First scenario :

Mail is send successfully if there are some email addresses in the TO and BCC fields. enter image description here

Wireshart snapshot 1

outcome: mail successfully sent.

Second scenario:

Mail is not successfully sent if there is nothing in the TO feild but only in BCC fields enter image description here

Wireshart snapshot 2

outcome: mail not sent

According to this I was not able to send the email because without TO: RCPT command can not be sent.

So the question is why MAIL FROM: is not sent when there is no email address in the TO:? Atleast MAIL FROM: should have been sent.

Community
  • 1
  • 1
no one
  • 477
  • 6
  • 19
  • can you show the code you use to send the mail? I just tried it and found that when I enter no TO address, the email is sent to the BCC recipients like it was addressed to them with TO. – P.J.Meisch Sep 09 '16 at 19:27
  • Wouldn't your comment invalidate the answer given in the hyperlink with reference to RFC 2821 ? – no one Sep 09 '16 at 20:24
  • RFC2821 is one thing, how clients and servers implement it is another one. Just had one more test: I did **not** add a TO address, but two BCC addresses. JavaMail used the first of the BCC addresses as TO and the second one for BCC. That is with javax.mail.mail.1.5.0-b01. In my last test I only had one BCC, so that was used as TO and no BCC was left over – P.J.Meisch Sep 10 '16 at 04:56
  • Just checked the source of com.sun.mail.smtp.SMTPTransport: when building the _RCPT TO:_ line the list of addresses is processed to find the first email address the server accepts as a valid address. There is no check if this was a TO or BCC recipient. The total list of recipients is then later added as corresponding headers. But for the RCPT, the first added address is used. So if you see a different behaviour, you might obviousl y use a different client implementation. – P.J.Meisch Sep 10 '16 at 05:07

0 Answers0