The application is running on Jboss server and using JNDI for getting email session. What I am trying to do is sending email to different address than passed to email api.
Application is passing recipient email address like:
PREFIX_email@example.com
I would like to strip PREFIX_ before sending the message. Preferable solution needs to be as transparent as possible.
Is there any ready to use solution for such case? What is best way of handling that?
If you can change the Session properties to redirect the email to another server, you have three choices:
Configure the other server to dump all messages into a single INBOX, then write a JavaMail program to fetch the messages from the INBOX, modify the email addresses, and send the modified message to the real SMTP server.
Write a "fake" SMTP server the accepts the message, rewrites the email addresses, and sends the message to the real SMTP server. You could use JavaMail to help with this.
Configure the SMTP server to do the address rewriting for you before forwarding the message. sendmail can certain do this, I don't know about others.
If you need it for development purpose I can recommend you a good solution for mocking javax.mail.Session
.
A github project javaMail extension adds file transport that allows to:
text
format instead of sending them mbox
format instead of sending them
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.