public SMTPMessageSender authenticate(String username, String password) throws IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException { if (smtpClient.auth(AuthenticatingSMTPClient.AUTH_METHOD.PLAIN, username, password) == false) { throw new SMTPSendingException(SmtpSendingStep.Authentication, smtpClient.getReplyString()); } return this; }
public static SMTPMessageSender authentication(String ip, int port, String senderDomain, String username, String password) throws NoSuchAlgorithmException, IOException, InvalidKeySpecException, InvalidKeyException { AuthenticatingSMTPClient smtpClient = new AuthenticatingSMTPClient(); smtpClient.connect(ip, port); if (smtpClient.auth(AuthenticatingSMTPClient.AUTH_METHOD.PLAIN, username, password) == false) { throw new RuntimeException("auth failed"); } return new SMTPMessageSender(smtpClient, senderDomain); }
client.auth(AuthenticatingSMTPClient.AUTH_METHOD.LOGIN, login, password); checkReply(client);