我想测试我的 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();
}
}
我是一名优秀的程序员,十分优秀!