本文整理汇总了Java中org.apache.commons.mail.Email.setTLS方法的典型用法代码示例。如果您正苦于以下问题:Java Email.setTLS方法的具体用法?Java Email.setTLS怎么用?Java Email.setTLS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.mail.Email
的用法示例。
在下文中一共展示了Email.setTLS方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupEmail
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
private void setupEmail(Email email) throws EmailException {
email.setHostName(getHostName());
email.setSslSmtpPort(getSmtpPort());
email.setFrom(getReplyAddress(), getReplyName());
if (StringUtils.isNotBlank(useSsl)) {
email.setSSL(Boolean.valueOf(getUseSsl()));
email.setSslSmtpPort(getSslPort());
}
if (StringUtils.isNotBlank(useTls)) {
email.setTLS(Boolean.valueOf(getUseTls()));
}
// use authentication if configured
if (StringUtils.isNotBlank(getAuthenticationUserName())) {
email.setAuthenticator(new DefaultAuthenticator(getAuthenticationUserName(), getAuthenticationPassword()));
}
}
示例2: setMailServerProperties
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void setMailServerProperties(Email email) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
String host = processEngineConfiguration.getMailServerHost();
if (host == null) {
throw new ActivitiException("Could not send email: no SMTP host is configured");
}
email.setHostName(host);
int port = processEngineConfiguration.getMailServerPort();
email.setSmtpPort(port);
email.setTLS(processEngineConfiguration.getMailServerUseTLS());
String user = processEngineConfiguration.getMailServerUsername();
String password = processEngineConfiguration.getMailServerPassword();
if (user != null && password != null) {
email.setAuthentication(user, password);
}
}
示例3: send
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public void send(String recipient, String subject, String content) throws SendMailException {
Assert.hasText(recipient);
Assert.hasText(subject);
Assert.hasText(content);
Email email = new SimpleEmail();
email.setHostName(host);
email.setAuthenticator(new DefaultAuthenticator(loginName, loginPassword));
email.setSmtpPort(port);
email.setTLS(tls);
try {
email.setCharset("UTF-8"); // specify the charset.
email.setFrom(fromAddress, fromName);
email.setSubject(subject);
email.setMsg(content);
email.addTo(recipient);
email.send();
} catch (EmailException e) {
throw new SendMailException(
String.format("Failed to send mail to %s.", recipient), e);
}
}
示例4: post
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
@Override
public String post(Email message) {
try {
message.setSmtpPort(587);
message.setAuthenticator(new DefaultAuthenticator("[email protected]", "3cWaN2jGhEbAAT"));
message.setDebug(false);
message.setHostName("smtp.gmail.com");
message.setFrom("The Job Announcer <[email protected]>");
message.setTLS(true);
message.send();
log.info("Mailed Notification with subject '" + message.getSubject() + "'.");
return message.toString();
} catch (EmailException e) {
log.warning("Failed to mail Notification with subject '" + message.getSubject() + "'.");
log.throwing(getClass().getName(), "post", e);
throw new RuntimeException(e);
}
}
示例5: setMailServerProperties
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void setMailServerProperties(Email email) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
String host = processEngineConfiguration.getMailServerHost();
if (host == null) {
throw new ActivitiException("Could not send email: no SMTP host is configured");
}
email.setHostName(host);
int port = processEngineConfiguration.getMailServerPort();
email.setSmtpPort(port);
email.setSSL(processEngineConfiguration.getMailServerUseSSL());
email.setTLS(processEngineConfiguration.getMailServerUseTLS());
String user = processEngineConfiguration.getMailServerUsername();
String password = processEngineConfiguration.getMailServerPassword();
if (user != null && password != null) {
email.setAuthentication(user, password);
}
}
示例6: setMailServerProperties
import org.apache.commons.mail.Email; //导入方法依赖的package包/类
protected void setMailServerProperties(Email email) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
String host = processEngineConfiguration.getMailServerHost();
ensureNotNull("Could not send email: no SMTP host is configured", "host", host);
email.setHostName(host);
int port = processEngineConfiguration.getMailServerPort();
email.setSmtpPort(port);
email.setTLS(processEngineConfiguration.getMailServerUseTLS());
String user = processEngineConfiguration.getMailServerUsername();
String password = processEngineConfiguration.getMailServerPassword();
if (user != null && password != null) {
email.setAuthentication(user, password);
}
}