使用 GWT 发送电子邮件 Java
Send an email using GWT Java
我一直在查看 Whosebug 中的电子邮件解决方案,并尝试使用以下解决方案:
EmailTask email = new SimpleEmail();
//Production
email.setHostName("mail.hostname.net");
email.setSmtpPort(25); //No authentication required
//Test
// email.setHostName("smtp.googlemail.com");
// email.setSmtpPort(587); //Authentication required
// email.setAuthenticator(new DefaultAuthenticator("me@gmail.com", "mypwd"));
email.setTLS(true);
email.setFrom("ATA@hostname.net");
email.setSubject("New Award Tracking Application account created.");
email.setMsg("Please set up a new Award Tracking Application account for: " + account);
email.addTo(to);
email.send();
System.out.println("Mail sent!");
在第一行 (EmailTask email = new SimpleEmail();
) 我收到错误
SimpleEmail cannot be resolved to a type
我在输入代码时按照快速修复导入了 import org.apache.tools.ant.taskdefs.email.EmailTask;
。我应该使用另一个库吗?
如有任何帮助,我们将不胜感激。
此致,
格林
在您的 class 路径 https://commons.apache.org/proper/commons-email/
中添加 Commons Email
检查 user guide 以获得简单示例。
Class SimpleEmail
GWT是一个前端框架,而你所要求的,发送邮件,是一个业务流程。
这个 link 可能会帮助您入门:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/javamail/javamail.html
我一直在查看 Whosebug 中的电子邮件解决方案,并尝试使用以下解决方案:
EmailTask email = new SimpleEmail();
//Production
email.setHostName("mail.hostname.net");
email.setSmtpPort(25); //No authentication required
//Test
// email.setHostName("smtp.googlemail.com");
// email.setSmtpPort(587); //Authentication required
// email.setAuthenticator(new DefaultAuthenticator("me@gmail.com", "mypwd"));
email.setTLS(true);
email.setFrom("ATA@hostname.net");
email.setSubject("New Award Tracking Application account created.");
email.setMsg("Please set up a new Award Tracking Application account for: " + account);
email.addTo(to);
email.send();
System.out.println("Mail sent!");
在第一行 (EmailTask email = new SimpleEmail();
) 我收到错误
SimpleEmail cannot be resolved to a type
我在输入代码时按照快速修复导入了 import org.apache.tools.ant.taskdefs.email.EmailTask;
。我应该使用另一个库吗?
如有任何帮助,我们将不胜感激。
此致,
格林
在您的 class 路径 https://commons.apache.org/proper/commons-email/
中添加 Commons Email检查 user guide 以获得简单示例。
Class SimpleEmail
GWT是一个前端框架,而你所要求的,发送邮件,是一个业务流程。
这个 link 可能会帮助您入门:http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/javamail/javamail.html