私の Web アプリは、ログインしているユーザーにメールを送信します。常に同じ設定を使用します。
mail.smtp.host=...
mail.smtp.user=...
mail.smtp.password=...
すべてのメッセージに対して connect-send-close を行うべきかどうか、私は混乱しています:
t.connect(host, username, password);
t.sendMessage(...);
t.close();
...または、一度だけ接続して、さまざまなメッセージを送信し続ける必要があります。
t.connect(host, username, password);
t.sendMessage(...);
t.sendMessage(...);
t.sendMessage(...);
t.sendMessage(...);
t.close();
...ホスト、ユーザー名、パスワードは変更されないため。
どうするのが正解?