public SMTPMessageSender(String senderDomain) { this(new AuthenticatingSMTPClient(), senderDomain); }
public static SMTPMessageSender noAuthentication(String ip, int port, String senderDomain) throws IOException { AuthenticatingSMTPClient smtpClient = new AuthenticatingSMTPClient(); smtpClient.connect(ip, port); return new SMTPMessageSender(smtpClient, senderDomain); }
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 = new AuthenticatingSMTPClient();