I have a class say TestEmail
which has a sendEmail()
method
Now the sendEmail
method calls an apache commons method which internally call methods from the javax.mail
package. I want to override one of the internal methods. I am providing the code flow below:
TestEmail.sendEmail()->
commons.Email.send()->commons.Email.sendMIMEMessage()->
javax.mail.Transport.send()->javax.mail.Transport(){saveChanges()}->
javax.mail.MimeMessage.updateHeaders()->updateMessageID()
I want to override the updateMessageID
method. within my TestEmail
class. Is it possible? How?
Looks like you would just override Email.createMimeMessage(Session) in which ever subclass of Email that you are using. Then have createMimeMessage return a subclass of javax.mail.MimeMessage that overrides updateMessageID to do what you want. If you just need to remove the userid then there are other ways to do that. See: Override Message-ID by configuration for details.