java smtp 163_javaMail 163 邮箱发 qq 邮箱 总是报 554 DT:SPM 163 smtp11

163 邮箱发 qq 邮箱 总是报 554 DT:SPM 163 smtp11

554 DT:SPM 发送的邮件内容包含了未被许可的信息,或被系统识别为垃圾邮件。请检查是否有用户发送病毒或者垃圾邮件;

发送了挺多次了 就只测试成功一次 ,然后写工具类后又失败了,执行原测试代码也一样,自己发给自己没问题

发送的内容都避免 test javvMail 等字眼了

配置:

spring.mail.host=smtp.163.com

[email protected]

spring.mail.password=xxxxxxx

spring.mail.protocol: smtp

spring.mail.properties.mail.smtp.auth: true

spring.mail.properties.mail.smtp.port: 994

spring.mail.properties.mail.smtp.starttls.enable: true

spring.mail.properties.mail.smtp.starttls.required: true

spring.mail.properties.mail.smtp.ssl.enable: true

spring.mail.default-encoding: utf-8

public static void sendSimpleMail(String to, String subject, String contnet){

JavaMailSender mailSender = BeanTool.getBean(JavaMailSender.class);

SimpleMailMessage message = new SimpleMailMessage();

message.setTo(to);

message.setSubject(subject);

message.setText(contnet);

message.setFrom(ConfigEmailValue.EMAIL_FROM);

mailSender.send(message);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java中可以使用JavaMail API来送邮件,其中SMTP协议是最常用的邮件送协议之一。下面是一个简单的示例代码: ```java import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SMTPJava { public static void main(String[] args) { final String username = "your_email@example.com"; final String password = "your_password"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.example.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("from@example.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to@example.com")); message.setSubject("Testing SMTP Java"); message.setText("Hello, this is a test email from SMTP Java"); Transport.send(message); System.out.println("Mail sent successfully"); } catch (MessagingException e) { throw new RuntimeException(e); } } } ``` 其中,需要修改的参数包括: - `username`和`password`:你的邮箱账号和密码; - `props.put("mail.smtp.host", "smtp.example.com");`:将`smtp.example.com`替换为你的邮箱提供商的SMTP服务器地址; - `message.setFrom(new InternetAddress("from@example.com"));`和`InternetAddress.parse("to@example.com")`:将`from@example.com`和`to@example.com`替换为你的件人和收件人的邮箱地址。 需要注意的是,有些邮箱提供商可能需要设置授权码(例如Gmail),可以在邮箱设置中找到授权码,并将其替换为密码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值