Search in sources :

Example 16 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project free-framework by a601942905git.

the class EmailService method sendSimpleMail.

/**
 * 发送纯文本的简单邮件
 * @param to
 * @param subject
 * @param content
 */
public void sendSimpleMail(String to, String subject, String content) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(content);
    try {
        sender.send(message);
        log.info("简单邮件已经发送。");
    } catch (Exception e) {
        log.error("发送简单邮件时发生异常!", e);
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MessagingException(javax.mail.MessagingException)

Example 17 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project bitcampSCOpen2017 by ryuyj.

the class SimpleRegistrationNotifier method sendMail.

// @Autowired
// private AES256Util aes256Util;
@Override
public void sendMail(Member member) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setSubject("[Simple] 회원 가입을 축하합니다.");
    message.setFrom("isincorp@gmail.com");
    message.setText("회원 가입을 환영합니다.");
    message.setTo(member.getEmail());
    // message.setTo(aes256Util.aesEncode(String.valueOf(member.getId())));
    try {
        mailSender.send(message);
    } catch (MailException ex) {
        ex.printStackTrace();
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException)

Example 18 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project bitcampSCOpen2017 by ryuyj.

the class SimpleRegistrationNotifier method sendMail.

public void sendMail(String email, String msg) {
    // 보내는 정보를 SimpleMailMessage 객체에 담는다.
    SimpleMailMessage message = new SimpleMailMessage();
    message.setSubject("[회원가입안내] 회원가입을 축하합니다.");
    message.setFrom("bpppys@gmail.com");
    message.setText(msg);
    message.setTo(email);
    mailSender.send(message);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 19 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project bitcampSCOpen2017 by ryuyj.

the class MemberRegService method memberReg.

public int memberReg(Member member, HttpServletRequest request) throws IllegalStateException, IOException {
    dao = sqlSessionTemplate.getMapper(LoginDao.class);
    // 파일 업로드 처리
    /*업로드 폴더 시스템 물리적 경로 찾기*/
    String uploadURI = "/uploadfile/memberphoto";
    String dir = request.getSession().getServletContext().getRealPath(uploadURI);
    System.out.println(dir);
    // 파일 이름 생성 : 회원아이디_원본파일이름
    if (!member.getPhotofile().isEmpty()) {
        // 새로운 파일 이름 생성 -> 파일 저장 -> DB에 저장할 파일이름 set
        String fileName = member.getMember_id() + "_" + member.getPhotofile().getOriginalFilename();
        member.getPhotofile().transferTo(new File(dir, fileName));
        member.setPhoto(fileName);
    }
    // 업로드한 파일의 데이터를 Member에 등록
    // dao 요청 : 데이터 저장 요청
    int resultCnt = dao.insertMember(member);
    System.out.println("샐행후:" + member.getIdx());
    // 메일보내기 설정
    SimpleMailMessage message = new SimpleMailMessage();
    // 제목설정
    message.setSubject(member.getMember_name() + "님 회원가입을 감사드립니다.");
    // 내용설정
    message.setText(member.getMember_name() + "님 회원가입을 감사드립니다.");
    // 가입회원의 메일주소 설정
    message.setTo(member.getMember_id());
    // 메일 발송
    // notifier.sendMail(member);
    notifier2.sendMail(member);
    return resultCnt;
}
Also used : LoginDao(com.bitcamp.open.member.dao.LoginDao) SimpleMailMessage(org.springframework.mail.SimpleMailMessage) File(java.io.File)

Example 20 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project FP-PSP-SERVER by FundacionParaguaya.

the class PasswordResetTokenServiceImpl method resetPassword.

@Override
public void resetPassword(String userEmail) {
    UserEntity user = null;
    try {
        user = userRepository.findUserByEmail(userEmail).get();
    } catch (NoSuchElementException e) {
        throw new CustomParameterizedException(i18n.translate("email.emailUserNotFound"));
    } catch (Exception ex) {
        throw new CustomParameterizedException(i18n.translate("email.errorResetMail"));
    }
    if (user == null) {
        throw new CustomParameterizedException(i18n.translate("email.emailUserNotFound"));
    }
    String token = UUID.randomUUID().toString();
    createPasswordResetTokenForUser(user, token);
    SimpleMailMessage template = new SimpleMailMessage();
    template.setText(loadTemplate(applicationProps.getTemplates().getResetMail()));
    String[] args = { i18n.translate("email.bodyTitle"), i18n.translate("email.bodyGreeting"), applicationProps.getClient().getLoginUrl() + "?" + MAIL_PARAM_TOKEN + "=" + token + "&" + MAIL_PARAM_ID + "=" + user.getId(), i18n.translate("email.bodyReset", user.getEmail()), i18n.translate("email.bodySign") };
    emailService.sendSimpleMessageUsingTemplate(user.getEmail(), i18n.translate("email.resetPassword"), template, args);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) CustomParameterizedException(py.org.fundacionparaguaya.pspserver.common.exceptions.CustomParameterizedException) UserEntity(py.org.fundacionparaguaya.pspserver.security.entities.UserEntity) NoSuchElementException(java.util.NoSuchElementException) NoSuchElementException(java.util.NoSuchElementException) CustomParameterizedException(py.org.fundacionparaguaya.pspserver.common.exceptions.CustomParameterizedException) IOException(java.io.IOException) UnknownResourceException(py.org.fundacionparaguaya.pspserver.common.exceptions.UnknownResourceException)

Aggregations

SimpleMailMessage (org.springframework.mail.SimpleMailMessage)103 MailException (org.springframework.mail.MailException)16 Test (org.junit.Test)12 Test (org.testng.annotations.Test)7 Test (org.junit.jupiter.api.Test)6 User (org.molgenis.data.security.auth.User)5 IOException (java.io.IOException)4 MessagingException (javax.mail.MessagingException)4 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 InternetAddress (jakarta.mail.internet.InternetAddress)3 MimeMessage (jakarta.mail.internet.MimeMessage)3 Date (java.util.Date)3 MimeMessage (javax.mail.internet.MimeMessage)3 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)3 MolgenisUserException (org.molgenis.security.user.MolgenisUserException)3 JavaMailSenderImpl (org.springframework.mail.javamail.JavaMailSenderImpl)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 User (fr.codechill.spring.model.User)2 User (gemma.gsec.model.User)2