JakartaMail
JavaMail の後継。ver 1.6.3 から EE4J の一部になった。
https://jakartaee.github.io/mail-api/
https://github.com/eclipse-ee4j/mail
セッションのプロパティ
https://jakarta.ee/specifications/mail/1.6/apidocs/com/sun/mail/smtp/package-summary.html
TODO 2.0.0 のドキュメントではどこに明記されているだろう
例外
session から transport を取得する際
NoSuchProviderException
transport で connect する際
AuthenticationFailedException : for authentication failures
MessagingException : for other failures
IllegalStateException : if the service is already connected
transport で送信する際
SendFailedException : if the send failed because of invalid addresses.
https://docs.oracle.com/javaee/6/api/javax/mail/SendFailedException.html
https://jakarta.ee/specifications/mail/2.0/apidocs/jakarta/mail/SendFailedException.html
送信に成功したアドレス、失敗したアドレスが取得できるが null が返ってくることもあるので注意
MessagingException : if the connection is dead or not in the connected state
メールの送信タイミング
Transport.sendMessage
https://jakarta.ee/specifications/mail/1.6/apidocs/javax/mail/Transport.html#sendMessage-javax.mail.Message-javax.mail.Address:A-
https://jakarta.ee/specifications/mail/2.0/apidocs/jakarta/mail/Transport.html#sendMessage(jakarta.mail.Message,jakarta.mail.Address%5B%5D)
呼び出された時点で送信を開始する
Transport の close は待たない
メール送信時のヘッダー
Multipart
Content-Transfer-Encoding
基本的には JakartaMail 側で自動的にセットされる
本文の内容によって base64 だったり quoted-printable する
どういう条件で変わるのかまでは調べてない #todo
#java #mail #smtp #JavaMail