[英]Javamail rate for the client exceeded
I need to send at least 200 messages from a stretch. 我需要至少发送200条消息。 When the program starts, send mail successfully to 15 or 17, then I get this error:
程序启动时,将邮件成功发送到15或17,然后出现此错误:
MESSAGE ERROR: 讯息错误:
com.sun.mail.smtp.SMTPSendFailedException: 421 4.4.2 Message submission rate for this client has exceeded the configured limit
What I can do? 我可以做什么?
public void mandarEmail(String correos, String mensaje, String asunto) {
Message message;
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.port", "587");
props.put("mail.smtp.host", "pod51004.outlook.com");
props.put("mail.smtp.debug", "true");
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("docemail@usmp.pe", "docpass");
}
});
try {
message = new MimeMessage(session);
message.setFrom(new InternetAddress("USMP - FN <documentos-fn@usmp.pe>"));
message.setSubject(asunto);
message.addRecipients(Message.RecipientType.TO, InternetAddress.parse(correos));
message.addRecipients(Message.RecipientType.BCC, new InternetAddress[]{new InternetAddress("ivan_pro_nice@hotmail.com")});
message.setContent(mensaje, "text/html; charset=utf-8");
Transport transport = session.getTransport("smtp");
transport.connect("docemail@usmp.pe", "docpass");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
} catch (MessagingException e) {
throw new RuntimeException(e);
} finally {
props = null;
message = null;
}
}
That's the server you're connecting to, and not a client issue. 那是您要连接的服务器,而不是客户端问题。 Here's a doc on how to parse SMTP codes from the server.
这是有关如何从服务器解析SMTP代码的文档 。
A mail server will reply to every request a client (such as your email program) makes with a return code.
邮件服务器将使用返回码答复客户端(例如您的电子邮件程序)的每个请求。 This code consists of three numbers.
该代码由三个数字组成。
In your case, you're getting 421
. 就您而言,您将获得
421
。
if you want to send single email to 200 clients. 如果要将单个电子邮件发送给200个客户。 Than u can add an array of reciever's email addresses of size upto 50. but i you want to send different msg for each email.
比您可以添加最多50个收件人的电子邮件地址数组。但是我想为每个电子邮件发送不同的味精。 Then you can create a new connection to email server with a counter that counts send emails as well as it counts 15 it should create a new connection.
然后,您可以使用一个计数器来建立与电子邮件服务器的新连接,该计数器可以计算发送电子邮件的数量,也可以计算创建新连接的15。
to test your code use mailtrap.io 使用mailtrap.io测试您的代码
您可能需要从邮件服务器供应商处购买一个“企业”帐户,以便他们可以发送更多电子邮件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.