本文整理汇总了Java中org.springframework.mail.javamail.JavaMailSenderImpl.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMailSenderImpl.setHost方法的具体用法?Java JavaMailSenderImpl.setHost怎么用?Java JavaMailSenderImpl.setHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mail.javamail.JavaMailSenderImpl
的用法示例。
在下文中一共展示了JavaMailSenderImpl.setHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRun
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Override
public void doRun(Collection<HealthCheck> healthChecks) {
if (!healthChecks.isEmpty()) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setSubject(subjectPrefix + " : " + healthChecks.size() + " failing checks");
message.setTo(to);
message.setText(buildMailContent(healthChecks));
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost(smtpHost);
sender.setPort(smtpPort);
userName.ifPresent(name -> sender.setUsername(name));
pwd.ifPresent(pwd -> sender.setPassword(pwd));
sender.send(message);
logger.info("Notification mail sent for " + healthChecks.size() + " health checks");
}
}
示例2: getMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
/**
* Return the {@link JavaMailSender} built from the given node.
*
* @param node
* The node holding the SMTP configuration.
* @return the {@link JavaMailSender} built from the given node.
*/
@CacheResult(cacheName = "plugin-data")
public JavaMailSender getMailSender(@CacheKey final String node) {
final JavaMailSenderImpl mail = new JavaMailSenderImpl();
final Map<String, String> parameters = pvResource.getNodeParameters(node);
mail.setUsername(parameters.get(PARAMETER_USER));
mail.setPassword(parameters.get(PARAMETER_PASSWORD));
mail.setHost(parameters.get(PARAMETER_HOST));
mail.setPort(Optional.ofNullable(parameters.get(PARAMETER_PORT)).map(Integer::valueOf).orElse(125));
mail.setDefaultEncoding("UTF-8");
final Properties properties = new Properties();
properties.put("mail.smtp.auth", Boolean.TRUE);
properties.put("mail.smtp.starttls.enable", Boolean.TRUE);
properties.put("mail.smtp.quitwait", Boolean.FALSE);
properties.put("mail.smtp.socketFactory.fallback", Boolean.FALSE);
mail.setJavaMailProperties(properties);
return mail;
}
示例3: updateJavaMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public void updateJavaMailSender() {
javaMailSender = new JavaMailSenderImpl();
javaMailSender.setHost(host);
javaMailSender.setPort(port);
if (smtpAuth) {
javaMailSender.setUsername(username);
javaMailSender.setPassword(password);
}
javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setJavaMailProperties(this.getProperties());
logger.debug("host : {}", host);
logger.debug("port : {}", port);
logger.debug("username : {}", username);
logger.debug("password : {}", password);
logger.debug("getProperties : {}", getProperties());
}
示例4: setUp
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
String mailServerHost = "127.0.0.1";
int mailServerPort = findAvailableTcpPort();
log.warn("Port selected: {}", mailServerPort);
greenMail = new GreenMail(
new ServerSetup(mailServerPort, mailServerHost, PROTOCOL_SMTP)
);
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost(mailServerHost);
sender.setPort(mailServerPort);
htmlEmailNotificationService = new HtmlEmailNotificationService("[email protected]", sender);
greenMail.start();
}
开发者ID:AppDirect,项目名称:service-integration-sdk,代码行数:18,代码来源:HtmlEmailNotificationServiceIntegrationTest.java
示例5: init
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@PostConstruct
public void init() {
// create new java mail sender
mailSender = new JavaMailSenderImpl();
// set mail sender configuration
mailSender.setHost(host);
mailSender.setPort(port);
mailSender.setProtocol(protocol);
mailSender.setUsername(username);
mailSender.setPassword(password);
// create java mail properties
Properties mailProperties = new Properties();
mailProperties.put("mail.smtp.auth", auth);
mailProperties.put("mail.smtp.starttls.enable", starttls);
mailProperties.put("mail.smtp.timeout", timeout);
mailProperties.put("mail.smtp.connectiontimeout", timeout);
// set java mail properties
mailSender.setJavaMailProperties(mailProperties);
}
示例6: mailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender mailSender() {
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost(this.properties.getHost());
sender.setPort(this.properties.getPort());
sender.setUsername(this.properties.getUsername());
sender.setPassword(this.properties.getPassword());
sender.setProtocol(this.properties.getProtocol());
sender.setDefaultEncoding(this.properties.getDefaultEncoding().name());
// extra properties
if (!this.properties.getProperties().isEmpty()) {
Properties mailProperties = new Properties();
mailProperties.putAll(this.properties.getProperties());
sender.setJavaMailProperties(mailProperties);
}
return sender;
}
示例7: build
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
private static JavaMailSender build(MailConfigSource config) {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setDefaultEncoding(StandardCharsets.UTF_8.name());
mailSender.setHost(config.mailServer().getHost());
mailSender.setPort(config.mailServer().getPort());
JProps mailProps = new JProps(mailSender.getJavaMailProperties());
configureTransport(config, mailProps);
config.username().ifPresent(
u -> configureAuthentication(config, u, mailSender, mailProps));
if (MailProtocol.smtps.equals(config.protocol())) {
configureTls(config, mailProps);
}
return mailSender;
}
示例8: javaMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
Properties mailProperties = new Properties();
mailProperties.put("mail.smtp.auth", auth);
mailProperties.put("mail.smtp.starttls.enable", starttls);
mailSender.setJavaMailProperties(mailProperties);
mailSender.setHost(host);
mailSender.setPort(port);
mailSender.setProtocol(protocol);
mailSender.setUsername(username);
mailSender.setPassword(password);
return mailSender;
}
示例9: javaMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
Properties mailProperties = new Properties();
mailProperties.put("mail.smtp.auth", auth);
mailProperties.put("mail.smtp.starttls.enable", starttls);
mailProperties.put("mail.smtp.starttls.required", startlls_required);
mailProperties.put("mail.smtp.socketFactory.port", socketPort);
mailProperties.put("mail.smtp.debug", debug);
mailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
mailProperties.put("mail.smtp.socketFactory.fallback", fallback);
mailSender.setJavaMailProperties(mailProperties);
mailSender.setHost(host);
mailSender.setPort(port);
mailSender.setProtocol(protocol);
mailSender.setUsername(username);
mailSender.setPassword(password);
return mailSender;
}
示例10: sendmail
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@RequestMapping(value = "sendmail", method = RequestMethod.POST, produces = { "application/xml", "application/json" })
public ResponseEntity<Email> sendmail(@RequestBody Email email) {
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
javaMailSender.setHost(email.getHost());
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(email.getFrom());
message.setTo(email.getTo());
message.setSubject(email.getSubject());
message.setText(email.getText());
try{
javaMailSender.send(message);
email.setStatus(true);
}catch(Exception e){
email.setText(e.getMessage());
email.setStatus(false);
}
return new ResponseEntity<Email>(email, HttpStatus.OK);
}
示例11: SendMail
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
public SendMail() {
mailBean = new MailBean();
mailSender = new JavaMailSenderImpl();
mailSender.setPort(mailBean.getPORT());
mailSender.setHost(mailBean.getHOST());
mailSender.setUsername(mailBean.getUSERNAME());
mailSender.setPassword(mailBean.getPASSWORD());
Properties properties = new Properties();
properties.setProperty("mail.smtp.auth", "true");
mailSender.setJavaMailProperties(properties);
mailMessage = new SimpleMailMessage();
mailMessage.setFrom(mailBean.getFROM());
mailMessage.setTo(mailBean.getTO());
mailMessage.setSubject(mailBean.getSUBJECT());
GetUserInfo getUserInfo = new GetUserInfo();
mailMessage.setText("[version]:" + LoadVersion.getVersion() + "\n[javaVersion]:" + getUserInfo.getJavaVersion()
+ "\n[osName]:" + getUserInfo.getOsName() + "\n[jvmName]:" + getUserInfo.getJvmName() + "\n[address]:"
+ getUserInfo.getAddress() + "\n[hostName]:" + getUserInfo.getHostname() + "\n[startTime]:"
+ getUserInfo.getStartTime());
}
示例12: mailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSenderImpl mailSender() {
JavaMailSenderImpl bean = new JavaMailSenderImpl();
bean.setHost(env.getProperty("mail.host"));
bean.setPort(Integer.valueOf(env.getProperty("mail.port")));
bean.setUsername(env.getProperty("mail.username"));
bean.setPassword(env.getProperty("mail.password"));
Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.auth", "true");
javaMailProperties.put("mail.smtp.starttls.enable", "true");
javaMailProperties.put("mail.smtp.auth.mechanisms", "LOGIN PLAIN");
javaMailProperties.put("mail.smtp.starttls.required", "true");
javaMailProperties.put("mail.smtp.ssl.trust", "*");
bean.setJavaMailProperties(javaMailProperties);
return bean;
}
示例13: javaMailSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Bean
public JavaMailSender javaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(config.getSmtpHost());
mailSender.setPort(config.getSmtpPort());
mailSender.setProtocol(config.getSmtpProtocol());
mailSender.setUsername(config.getSmtpUsername());
mailSender.setPassword(config.getSmtpPassword());
mailSender.setDefaultEncoding("UTF-8");
if ("smtps".equalsIgnoreCase(config.getSmtpProtocol())) {
Properties mailProperties = new Properties();
mailProperties.setProperty("mail.smtps.auth", "true");
mailProperties.setProperty("mail.smtp.ssl.enable", "true");
mailProperties.setProperty("mail.transport.protocol", "smtps");
mailProperties.setProperty("mail.debug", "true");
mailProperties.setProperty("mail.mime.charset", "utf8");
mailSender.setJavaMailProperties(mailProperties);
}
return mailSender;
}
示例14: start
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
@Override
public void start() {
super.start();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setUsername(emailUsername);
mailSender.setPassword(emailPassword);
mailSender.setHost(emailHost);
mailSender.setDefaultEncoding("UTF-8");
Properties pros = new Properties();
pros.put("mail.smtp.auth", true);
pros.put("mail.smtp.timeout", 25000);
pros.put("mail.smtp.port", stmpPort);
pros.put("mail.smtp.socketFactory.port", stmpPort);
pros.put("mail.smtp.socketFactory.fallback", false);
if (sslSupport) {
pros.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}
mailSender.setJavaMailProperties(pros);
this.mailSender = mailSender;
}
示例15: createSender
import org.springframework.mail.javamail.JavaMailSenderImpl; //导入方法依赖的package包/类
protected JavaMailSenderImpl createSender(Map<ApplicationPropertyMailing, String> settings) {
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setProtocol(PROTOCOL);
sender.setHost(settings.get(ApplicationPropertyMailing.HOST));
sender.setPort(getPort(settings));
Properties mailingProperties = new Properties();
String login = settings.get(ApplicationPropertyMailing.LOGIN);
if (StringUtils.isNotEmpty(login)) {
sender.setUsername(login);
mailingProperties.setProperty("mail.smtp.auth", "true");
String password = settings.get(ApplicationPropertyMailing.PASSWORD);
if (StringUtils.isNotEmpty(password)) {
// expect non-encrypted password!
sender.setPassword(password);
}
}
mailingProperties.setProperty("mail.smtp.starttls.enable", getStartTls(settings));
sender.setJavaMailProperties(mailingProperties);
return sender;
}