Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Different TO and RCPT fields?

843830Jan 19 2004 — edited Jan 21 2004
Hi,

Using JavaMail, is it possible to send an email to a particular address yet have the "To" field (header) show something else?

I know in SMTP (I just tried it and it works) , you can do something like this:

mail from: me@someaccount.com
rcpt to: you@anotheraccount.com
data
To: somealias@nowhere.com
blah blah
.

And the effect will be that a mail message will be sent to "you@anotheraccount.com" but the "To" field will say that it is to "somealias@nowhere.com".

I've been trying to do the same thing in JavaMail but haven't had any luck. I can set the actual recipient via JavaMail using the "setRecipients" method--no problem. But when I try to change what gets displayed in the "To" header, it doesn't work.

I've tried the "addHeader" and "addHeaderLine" methods in MimeMessage. I've also tried setting the "mail.smtp.to". No luck, either way.

I have a ~feeling~ that this is just not possible with JavaMail. Can someone confirm this or show me how it's done?

Thanks,
Thomas
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2004
Added on Jan 19 2004
1 comment
165 views