あるアプリケーションでは、Java を使用してメール送信ロジックを実装しました。有効な Gmail ID とパスワードを使用smtp.gmail.com
しました。587 port
開発環境では、すべて正常に動作しています。しかし、実稼働環境では、そのドメインで有効な電子メール ID とパスワードを使用smtp.xyz.in
して、別のメール サーバーを使用する必要があります。port 25
次のコードで SSL を有効にすると、次のようになります。
エラーが発生します
Could not convert socket to TLS
SunCertPathBuilderException: Unable To Find Valid Certification Path To Requested Target
================================================== =====
final ResourceBundle rsbd=ResourceBundle.getBundle("main/ResourceBundle/Dyna");
// -- Attaching to default Session, or we could start a new one
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.port", port);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.EnableSSL.enable","true");
Session session =Session.getInstance(props, new Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(admin_mail, admin_password);}});
// -- Create a new message --
Message msg = new MimeMessage(session);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email, false));
msg.setSubject(subject);
msg.setText(emailContent);
// -- Set some other header information --
msg.setHeader("X-Mailer", "LOTONtechEmail");
msg.setSentDate(new Date());
// -- Send the message --
Transport.send(msg);
EnableSSL を削除して、次のコードを追加しようとすると:
(getting javax.mail.AuthenticationFailedException:535 5.7.3 Authentication unsuccessful)
================================================== ========================
props.put("mail.smtp.socketFactory.port","25");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "true");
MailSSLSocketFactory sf=new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.socketFactory", sf);
過去 3 日間で十分にグーグルで検索した結果、こちらのように信頼できる証明書を構成する必要があることを理解しました。
しかし、SSL を有効にするために、暗号化も盗用もせずに続行したいと考えています。SSL を有効にせずに、独自のドメインを介して Java プログラムで電子メールを送信する方法はありますか。どんな助けでも大歓迎です。