当前位置: 首页>>代码示例>>Java>>正文


Java JavaMailSenderImpl类代码示例

本文整理汇总了Java中org.springframework.mail.javamail.JavaMailSenderImpl的典型用法代码示例。如果您正苦于以下问题:Java JavaMailSenderImpl类的具体用法?Java JavaMailSenderImpl怎么用?Java JavaMailSenderImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaMailSenderImpl类属于org.springframework.mail.javamail包,在下文中一共展示了JavaMailSenderImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMailWithUsername

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithUsername(
        @NotBlank @Email final String email,
        @NotBlank final String username
) {
    log.info("Called with e-mail {}, username {}", email, username);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Recover username");
        helper.setText("Your username: " + "<b>" + username + "</b>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:28,代码来源:MailServiceImpl.java

示例2: javaMailService

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
@Bean
public JavaMailSender javaMailService() {
    JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();

    if (this.auth) {
        javaMailSender.setUsername(this.username);
        javaMailSender.setPassword(this.password);
    }

    Properties properties = new Properties();
    properties.setProperty("mail.transport.protocol", this.protocol);
    properties.setProperty("mail.smtp.auth", Boolean.toString(this.auth));
    properties.setProperty("mail.smtp.starttls.enable", Boolean.toString(this.starttls));
    properties.setProperty("mail.debug", Boolean.toString(this.debug));
    properties.setProperty("mail.smtp.host", this.host);
    properties.setProperty("mail.smtp.port", Integer.toString(this.port));
    properties.setProperty("mail.smtp.ssl.trust", this.trust);
    javaMailSender.setJavaMailProperties(properties);

    return javaMailSender;
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:22,代码来源:MailService.java

示例3: 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");
    }
}
 
开发者ID:gilles-stragier,项目名称:quickmon,代码行数:22,代码来源:MailNotifier.java

示例4: 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;
}
 
开发者ID:ligoj,项目名称:plugin-mail-smtp,代码行数:27,代码来源:SmtpPluginResource.java

示例5: 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());
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:MailServerInfo.java

示例6: testHealthCommand

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
@Test
public void testHealthCommand() {
    int smtpPort = SocketUtils.findAvailableTcpPort();
    ServerSetup setup = new ServerSetup(smtpPort, null, ServerSetup.PROTOCOL_SMTP);
    setup.setServerStartupTimeout(5000);
    GreenMail mailServer = new GreenMail(setup);
    mailServer.start();
    ((JavaMailSenderImpl) mailSender).setPort(smtpPort);
    sshCallShell((is, os) -> {
        write(os, "health");
        verifyResponse(is, "{\r\n  \"status\" : \"UP\"");
        mailServer.stop();
    });
}
 
开发者ID:anand1st,项目名称:sshd-shell-spring-boot,代码行数:15,代码来源:SshdShellAutoConfigurationTest.java

示例7: 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

示例8: sendMailWithNewPassword

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Async
@Override
public void sendMailWithNewPassword(
        @NotBlank @Email final String email,
        @NotBlank final String newPassword
) {
    log.info("Called with e-mail {}, newPassword {}", email, newPassword);

    try {
        final JavaMailSenderImpl sender = new JavaMailSenderImpl();

        final MimeMessage message = sender.createMimeMessage();

        final MimeMessageHelper helper = new MimeMessageHelper(message);

        helper.setTo(email);
        helper.setSubject("Recover password");
        helper.setText("Your new password: " + "<b>" + newPassword + "</b>", true);

        sendMail(message);
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:28,代码来源:MailServiceImpl.java

示例9: 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);
}
 
开发者ID:chrisipa,项目名称:cloud-portal,代码行数:24,代码来源:MailService.java

示例10: 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;
}
 
开发者ID:mychalvlcek,项目名称:spring-rest-skeleton,代码行数:18,代码来源:EmailConfiguration.java

示例11: 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;
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:18,代码来源:MailClientAdapter.java

示例12: 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;
}
 
开发者ID:oojorgeoo89,项目名称:QuizZz,代码行数:17,代码来源:MailConfig.java

示例13: 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;
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:22,代码来源:MailConfiguration.java

示例14: testStatusCommand

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
@Test
public void testStatusCommand() {
    int smtpPort = SocketUtils.findAvailableTcpPort();
    ServerSetup setup = new ServerSetup(smtpPort, null, ServerSetup.PROTOCOL_SMTP);
    setup.setServerStartupTimeout(5000);
    GreenMail mailServer = new GreenMail(setup);
    mailServer.start();
    ((JavaMailSenderImpl) mailSender).setPort(smtpPort);
    sshCallShell((is, os) -> {
        write(os, "status");
        verifyResponse(is, "{\r\n  \"status\" : \"UP\"\r\n}");
        mailServer.stop();
    });
}
 
开发者ID:anand1st,项目名称:sshd-shell-spring-boot,代码行数:15,代码来源:SshdShellAutoConfigurationTest.java

示例15: sendEmailMsg

import org.springframework.mail.javamail.JavaMailSenderImpl; //导入依赖的package包/类
private void sendEmailMsg(String email, String content) {
	logger.info("kaishi");
	JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
       // 设定mail server
       senderImpl.setHost(mailHost);
       senderImpl.setUsername(mailUserName);
       senderImpl.setPassword(mailPassword);

       Properties prop = new Properties();
       // 将这个参数设为true,让服务器进行认证,认证用户名和密码是否正确
       prop.put("mail.smtp.auth", "true");
       prop.put("mail.smtp.timeout", "25000");// milliseconds
       senderImpl.setJavaMailProperties(prop);
       // 建立邮件消息
       SimpleMailMessage mailMessage = new SimpleMailMessage();

       mailMessage.setTo(email);
       mailMessage.setFrom(mailSender);
       mailMessage.setSubject("sam验证码");
       mailMessage.setText(content);

       // 发送邮件
       senderImpl.send(mailMessage);

       logger.info("successfully send mail");
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:27,代码来源:EmailSendServiceImpl.java


注:本文中的org.springframework.mail.javamail.JavaMailSenderImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。