bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)
http://www.simplejavamail.org
Apache License 2.0
1.2k stars 261 forks source link

How to create jakarta.mail.internet.MimeMessage without accessing the mailer session? #509

Closed Aaron0176 closed 2 months ago

Aaron0176 commented 2 months ago

I'm doing the following to create a MimeMessage with the current mailer session:

MimeMessage mimeMessage = new MimeMessage(session);

In the logs I read "Providing access to Session instance for emergency fall-back scenario"

What would be the recommended approach?

bbottema commented 2 months ago

I'm confused as to what you are trying to achieve. You call a MimeMessage constructor, which is not part of the Simple Java Mail api, but then you cite a log line coming from Simple Java Mail api usage.

Aaron0176 commented 2 months ago

I want to create a MimeMessage using jakarta.mail.internet.MimeMessage. Therefor I need the session parameter. Works as expected.

I was just confused because I then saw in the logs that in general I should NOT use the session parameter...

bbottema commented 2 months ago

It's still not clear.

I want to create a MimeMessage using jakarta.mail.internet.MimeMessage. Therefor I need the session parameter. Works as expected.

Ok sure, but this has nothing to do with your second statement:

I was just confused because I then saw in the logs that in general I should NOT use the session parameter...

You can do the first without even having Simple Java Mail on your classpath. So I don't see the connection between you calling new MimeMessage(session) and the log message "Providing access to Session instance for emergency fall-back scenario".