简体   繁体   中英

Sending mail by setting recipient address in setHeader() method - java mail

Is there any way to add Recipient address using setHeader() like

message.setHeader("To:","mail@domain.com");

I tried the above one and it is not working. Please correct me if I am wrong.

I need an alternative for the following code:

InternetAddress mail_to = new InternetAddress("mail_id@domain.com","Name_of_recipient");
message.addRecipient(Message.RecipientType.TO, mail_to);

My requirement is to skip RFC822 email format check.

The header name is "To", without the colon.

But you're not going to get very far with an incorrectly formatted address. Even if JavaMail doesn't detect the error, the server most likely will.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM