| | |
| | | |
| | | import com.ruoyi.common.config.MailProperties; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.sun.xml.internal.org.jvnet.mimepull.MIMEMessage; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Properties; |
| | | import javax.mail.*; |
| | | import javax.mail.internet.InternetAddress; |
| | | import javax.mail.internet.MimeMessage; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Properties; |
| | | |
| | | @Component |
| | | @Slf4j |
| | |
| | | @Autowired |
| | | MailProperties properties; |
| | | |
| | | public MailProperties getPro() { |
| | | return properties; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param emailAddress 邮件接收者email地址 |
| | | * @param param 用户房屋地址参数 |
| | | */ |
| | | public void send(String emailAddress,String param){ |
| | | // 配置发送邮件的环境属性 |
| | | final Properties props = new Properties(); |
| | |
| | | //发送邮件 |
| | | Transport.send(message); |
| | | } catch (MessagingException | UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | log.error("发送邮件发生异常",e); |
| | | throw new ServiceException("发送邮件失败,请检查"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.error("发送邮件发生异常",e); |
| | | } |
| | | |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // TencentMailUtil tencentMailUtil = new TencentMailUtil(); |
| | | // MailProperties properties = new MailProperties(); |
| | | // tencentMailUtil.properties = properties; |
| | | // tencentMailUtil.send("214491528@qq.com","大学城揽院24栋"); |
| | | // |
| | | // } |
| | | public static void main(String[] args) { |
| | | TencentMailUtil tencentMailUtil = new TencentMailUtil(); |
| | | MailProperties properties = new MailProperties(); |
| | | tencentMailUtil.properties = properties; |
| | | tencentMailUtil.send("214491528@qq.com","大学城揽院24栋"); |
| | | |
| | | } |
| | | |
| | | |
| | | |