メールを一括送信する方法を書きましたが、非常に遅いです (10 秒ごとに約 3 メール)。何千ものメールを送信したい。これをもっと速く行う方法はありますか?
私は現在gmailを使用していますが、テストのためだけに使用しています.最終的には、自分のSMTPサーバーを使用して送信したいと考えています.
コードは次のとおりです。
public boolean sendMessages()
{
try
{
Session session = Session.getInstance(this._properties, new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("user", "password");
}
});
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(this.getFrom()));
message.setSubject(this.getSubject());
message.setText(this.getBody());
for (int i = 0, c = this._addresses.size(); i < c; i++)
{
message.setRecipient(Message.RecipientType.TO, new InternetAddress(this._addresses.get(i)));
Transport.send(message);
}
return true;
}
catch(AuthenticationFailedException e) {
e.printStackTrace();
return false;
}
catch(MessagingException e) {
e.printStackTrace();
return false;
}
}