gpt4 book ai didi

java - 如何向不同的电子邮件 ID 批量发送电子邮件

转载 作者:太空宇宙 更新时间:2023-11-04 12:51:28 25 4
gpt4 key购买 nike

我想测试我的 Emil Com 服务器和 SMTP 容量。所以我需要从我的应用程序将邮件发送到不同的电子邮件帐户。但我不能每次都创建 10000 个邮件 ID。是否有任何模拟工具可用于从我的应用程序发送电子邮件而无需创建邮件 ID(Gmail、yahoo 等)

最佳答案

Use this method emailNotification() and implement as per your need. Concatinate all the email_id with a comma seprator abc@abc.com,abc1@abc.com,abc2@abc.com and pass the string to the v_sBCC.

这个功能可能会帮到你。谢谢..

 private void emailNotification(){
String v_sTo;
String v_sFrom;
String v_sBCC = "abc@gmail.com,abc1@gmail.com" //add a number of emails with a Comma separator.
DataSource v_objSource;
Properties v_objProperties;
Session v_objSession;
MimeMessage v_sMessage;
BodyPart v_objMessageBodyPart;
Multipart v_objMultipart;
try {
v_sFrom = "Set From Name To Show User that From which Email you received Mail";
v_objProperties = new Properties();
v_objProperties.put("mail.smtp.host", smtp.google.com);
v_objProperties.put("mail.smtp.auth", "true");
v_objProperties.put("mail.debug", "false");
v_objProperties.put("mail.smtp.port", 25);
v_objProperties.put("mail.smtp.socketFactory.port", 25);
v_objProperties.put("mail.smtp.starttls.enable", "true");
v_objProperties.put("mail.transport.protocol", "smtp");
v_objSession = Session.getInstance(v_objProperties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("gmail.id", "password");
}
});
v_sMessage = new MimeMessage(v_objSession);
v_sMessage.setFrom(new InternetAddress(v_sFrom, "Your Company Name"));
v_sMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(v_sTo));
v_sMessage.addRecipient(Message.RecipientType.BCC, new InternetAddress(v_sBCC));
v_sMessage.setSubject("Set Your Own Subject");
v_sMessage.setText("Set Your Own Body");
Transport.send(v_sMessage);
} catch (MessagingException v_exException) {
v_exException.printStackTrace();
} catch (UnsupportedEncodingException v_exException) {
v_exException.printStackTrace();
}
}

关于java - 如何向不同的电子邮件 ID 批量发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789781/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com