public static void Main(string[] args) { // http://commons.apache.org/proper/commons-email/apidocs/index.html // http://commons.apache.org/proper/commons-email/apidocs/org/apache/commons/mail/Email.html // https://commons.apache.org/proper/commons-email/userguide.html // can we have udp registry for settings yet? try { var email = new org.apache.commons.mail.SimpleEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); // https://commons.apache.org/proper/commons-email/apidocs/org/apache/commons/mail/DefaultAuthenticator.html email.setAuthenticator(new org.apache.commons.mail.DefaultAuthenticator("username", "password")); email.setSSLOnConnect(true); email.setFrom("*****@*****.**"); email.setSubject("TestMail"); email.setMsg("This is a test mail ... :-)"); email.addTo("*****@*****.**"); email.send(); } catch (Exception err) { // { err = org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:465 } Console.WriteLine(new { err }); } Console.WriteLine("done"); Console.ReadLine(); }
protected internal virtual SimpleEmail createTextOnlyEmail(string text) { SimpleEmail email = new SimpleEmail(); try { email.Msg = text; return(email); } catch (EmailException e) { throw LOG.emailCreationException("text-only", e); } }