-1
public static void sendEmail(String mailTo, String mailCC, String subject, String content)
{
Properties properties = System.getProperties();
properties.setProperty("mail.transport.protocol", "smtp");
properties.setProperty("mail.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.socketFactory.fallback", "false");
properties.setProperty("mail.smtp.quitwait", "false");
properties.put("mail.smtp.port","465");
try {
Session session = Session.getDefaultInstance(properties,
new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
"[email protected]", "XXXXXX");
}
});
Message message = new MimeMessage(session);
Address fromAddress = new InternetAddress("[email protected]");
Address toAdd = new InternetAddress(mailTo);
Address ccAdd = new InternetAddress(mailCC);
message.setFrom(fromAddress);
message.setRecipient(Message.RecipientType.TO, toAdd);
message.setRecipient(Message.RecipientType.CC, ccAdd);
message.setSubject(subject);
Transport.send(message);
} catch (Exception e) {
e.printStackTrace();
}
}
私はerror.Please下に直面していますが、次のことを行う必要がありSMTPエラー
以下はどのようなエラーが表示されるのですか? – Tibrogargan