Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I explicitly set the SMTP FROM: attribute when sending a message?

explicitly message SMTP
0
Posted

How can I explicitly set the SMTP FROM: attribute when sending a message?

0

mail.smtp.from property can be used to set the SMTP FROM: attribute. If this property if absent, the message’s From attribute is used. If multiple threads need to send mail simultaneously, and each needs to set the From attribute, each thread should use its own Session object with its own Properties object. The mail.smtp.from property can then be set on each Properties object for each Session (and thus each thread) independently. Alternatively, each thread can use the com.sun.mail.SMTPMessage class. The setEnvelopeFrom method on that class can be used to set this value. With this approach, all threads can use the same Session.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.