添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

发送明文邮件时,需要设置好:

  • 协议(默认是smtp,可不用设置)
  • host
  • 端口(默认是25)
  • 用户名
  • 密码
  • 开启身份验证(mail.smtp.auth=true)

网易企业邮箱 不再支持明文邮件了。使用此种方式调用时,会获得错误:535 5.7.0 ERR.LOGIN.NONSSL

JavaMailSenderImpl发送邮件,示例代码如下:

public class TestSendMail1 {
	private static Logger log = LoggerFactory.getLogger(TestSendMail1.class);
	public static void main(String[] args) throws Exception {
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
		mailSender.setHost("smtphz.qiye.163.com");
		mailSender.setPort(25);
		mailSender.setUsername("xxx@mydomain.com");
		mailSender.setPassword("123456");
		Properties javaMailProperties = mailSender.getJavaMailProperties();
		javaMailProperties.setProperty("mail.smtp.auth", "true"); 
		javaMailProperties.setProperty("mail.debug", "true");//启用调试
    	javaMailProperties.setProperty("mail.smtp.timeout", "3000"); //设置超时时间3秒
		mailSender.setJavaMailProperties(javaMailProperties);
			MimeMessage mailMessage = mailSender.createMimeMessage();
			MimeMessageHelper helper = new MimeMessageHelper(mailMessage, true, "UTF-8");
			helper.setFrom("xxx@mydomain.com");
			helper.setTo("xxx@mydomain.com");
			helper.setSubject("测试邮件:您有一个新的未处理消息(使用明文发送)");
			helper.setText(String.format("hi,%s: <br/><br/><br/>很高兴认识你!", "张三"), true);
            mailSender.send(mailMessage);
        }catch (Exception e) {
            log.error("发送邮件失败", e);

springboot mail插件发送邮件,配置如下(示例代码在后面):

spring.mail.host=smtphz.qiye.163.com
spring.mail.username=xxx@mydomain.com
spring.mail.password=123456
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.debug=true
spring.mail.properties.mail.smtp.ssl.enable=false
spring.mail.properties.mail.imap.ssl.socketFactory.fallback=false
spring.mail.properties.mail.smtp.ssl.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false

TLS加密

发送明文邮件时,需要设置好:

  • 协议(默认是smtp,可不用设置)
  • host
  • 端口(默认情况下,TLS加密使用25端口)
  • 用户名
  • 密码
  • 开启身份验证(mail.smtp.auth=true)
  • 支持TLS加密(mail.smtp.starttls.required = true)

TLS加密使用25端口 ! TLS加密使用25端口 ! TLS加密使用25端口!

JavaMailSenderImpl发送邮件,示例代码如下:

public class TestSendMail2 {
	private static Logger log = LoggerFactory.getLogger(TestSendMail2.class);
	public static void main(String[] args) throws Exception {
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
		mailSender.setHost("smtphz.qiye.163.com");
		mailSender.setPort(25);
		mailSender.setUsername("xxx@mydomain.com");
		mailSender.setPassword("123456");
		Properties javaMailProperties = mailSender.getJavaMailProperties();
		javaMailProperties.setProperty("mail.smtp.auth", "true"); 
		javaMailProperties.setProperty("mail.debug", "true");//启用调试
    	javaMailProperties.setProperty("mail.smtp.timeout", "3000"); //设置超时时间3秒
    	javaMailProperties.setProperty("mail.smtp.starttls.enable", "true");
    	javaMailProperties.setProperty("mail.smtp.starttls.required", "true");
    	javaMailProperties.setProperty("mail.smtp.ssl.enable", "false");
    	javaMailProperties.setProperty("mail.imap.ssl.socketFactory.fallback", "false");
    	javaMailProperties.setProperty("mail.smtp.ssl.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		mailSender.setJavaMailProperties(javaMailProperties);
			MimeMessage mailMessage = mailSender.createMimeMessage();
			MimeMessageHelper helper = new MimeMessageHelper(mailMessage, true, "UTF-8");
			helper.setFrom("xxx@mydomain.com");
			helper.setTo("xxx@mydomain.com");
			helper.setSubject("测试邮件:您有一个新的未处理消息(使用TLS加密发送)");
			helper.setText(String.format("hi,%s: <br/><br/><br/>很高兴认识你!", "张三"), true);
            mailSender.send(mailMessage);
        }catch (Exception e) {
            log.error("发送邮件失败", e);

springboot mail插件发送邮件,配置如下(示例代码在后面):

spring.mail.host=smtphz.qiye.163.com
spring.mail.username=xxx@mydomain.com
spring.mail.password=123456
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.debug=true
spring.mail.properties.mail.smtp.ssl.enable=false
spring.mail.properties.mail.imap.ssl.socketFactory.fallback=false
spring.mail.properties.mail.smtp.ssl.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=true

SSL加密

发送明文邮件时,需要设置好:

  • 协议(默认是smtp,可不用设置)
  • host
  • 端口(默认情况下,SSL加密使用456端口)
  • 用户名
  • 密码
  • 开启身份验证(mail.smtp.auth=true)
  • 支持SSL加密(mail.smtp.ssl.enable = true)

网易企业邮箱 SSL 端口994

JavaMailSenderImpl发送邮件,示例代码如下:

public class TestSendMail3 {
	private static Logger log = LoggerFactory.getLogger(TestSendMail3.class);
	public static void main(String[] args) throws Exception {
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
		mailSender.setHost("smtphz.qiye.163.com");
		mailSender.setPort(994);
		mailSender.setUsername("xxx@mydomain.com");
		mailSender.setPassword("123456");
		Properties javaMailProperties = mailSender.getJavaMailProperties();
		javaMailProperties.setProperty("mail.smtp.auth", "true"); 
		javaMailProperties.setProperty("mail.debug", "true");//启用调试
    	javaMailProperties.setProperty("mail.smtp.timeout", "3000"); //设置超时时间3秒
    	javaMailProperties.setProperty("mail.smtp.starttls.enable", "false");
    	javaMailProperties.setProperty("mail.smtp.starttls.required", "false");
    	javaMailProperties.setProperty("mail.smtp.ssl.enable", "true");
    	javaMailProperties.setProperty("mail.imap.ssl.socketFactory.fallback", "false");
    	javaMailProperties.setProperty("mail.smtp.ssl.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		mailSender.setJavaMailProperties(javaMailProperties);
			MimeMessage mailMessage = mailSender.createMimeMessage();
			MimeMessageHelper helper = new MimeMessageHelper(mailMessage, true, "UTF-8");
			helper.setFrom("xxx@mydomain.com");
			helper.setTo("xxx@mydomain.com");
			helper.setSubject("测试邮件:您有一个新的未处理消息(使用SSL加密发送)");
			helper.setText(String.format("hi,%s: <br/><br/><br/>很高兴认识你!", "张三"), true);
            mailSender.send(mailMessage);
        }catch (Exception e) {
            log.error("发送邮件失败", e);

springboot mail插件发送邮件,SSL加密,配置如下(示例代码在后面):

spring.mail.host=smtphz.qiye.163.com
spring.mail.username=xxx@mydomain.com
spring.mail.password=123456
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.debug=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.imap.ssl.socketFactory.fallback=false
spring.mail.properties.mail.smtp.ssl.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false

springboot mail插件发送邮件 示例

@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class)
@TestPropertySource("classpath:application-TestSendMail3.properties")
public class TestSendMail4 {
	private Logger log = LoggerFactory.getLogger(TestSendMail4.class);
	@Autowired
	private JavaMailSenderImpl mailSender;
	@Test
    public void test01() {
			MimeMessage mailMessage = mailSender.createMimeMessage();
			MimeMessageHelper helper = new MimeMessageHelper(mailMessage, true, "UTF-8");
			helper.setFrom("xxx@mydomain.com");
			helper.setTo("xxx@mydomain.com");
			helper.setSubject("测试邮件:您有一个新的未处理消息(使用 spring boot 发送)");
			helper.setText(String.format("hi,%s: <br/><br/><br/>很高兴认识你!", "张三"), true);
            mailSender.send(mailMessage);
        }catch (Exception e) {
            log.error("发送邮件失败", e);

application-TestSendMail3.properties

spring.mail.host=smtphz.qiye.163.com
spring.mail.username=xxx@mydomain.com
spring.mail.password=123456
spring.mail.port=25
spring.mail.protocol=smtp
spring.mail.default-encoding=UTF-8
spring.mail.properties.mail.smtp.timeout=3000
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.debug=true
spring.mail.properties.mail.smtp.ssl.enable=false
spring.mail.properties.mail.imap.ssl.socketFactory.fallback=false
spring.mail.properties.mail.smtp.ssl.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=true

网易企业邮箱从这里 查协议、host、端口

https://qiye.163.com/help/client.html?device=pc

网易企业邮箱错误码: 420 ERR.LOGIN.DOMAINNOTEXIST 错误

查到的host不对。按照前面的说明查host。

网易企业邮其它错误码

"ERR.LOGIN.USERORPASSNULL":"参数错误:用户名或者密码为空",
"ERR.LOGIN.DOMAINNULL":"参数错误:未指定的域邮箱参数",
"ERR.LOGIN.PASSERR":"用户名和密码不匹配",
"ERR.LOGIN.ILLEGALACCOUNT":"该帐号属于群发名单或者别名,不允许登录",
"ERR.LOGIN.USERNOTEXIST":"该帐号不存在,请你确认域名和帐号",
"ERR.LOGIN.SUPERADMINDOMAINERR":"该超级管理员并未申请任何域名邮箱",
"ERR.LOGIN.SYSTEMBUSY":"登录系统繁忙,请你稍后再试",
"ERR.LOGIN.IPDENY":"登录失败,你的IP在黑名单中,请你联系客服",
"ERR.LOGIN.USRSTATUS1":"该帐号已被禁用,请联系管理员",
"ERR.LOGIN.USRSTATUS2":"帐号已过期,请联系管理员",
"ERR.LOGIN.USRSTATUS5":"该帐号已被管理员删除,请联系管理员",
"SUC.LOGIN.USRUNLOCK":"该帐号已解除冻结状态,请你再次输入用户和密码继续",
"ERR.LOGIN.DOMAINEXPED":"该域名邮箱已经过期了",
"ERR.LOGIN.DOMAINNOTREGISTER":"该域名尚未通过,请以超级管理员登录",
"ERR.LOGIN.DOMAINSTATUS1":"该域名邮箱已被禁用,请你联系客服",
"ERR.SESSIONNULL":"会话已经失效,请你重新登录操作",
"ERR.SYSTEM":"系统繁忙,请你稍后再试",
"ERR.ADMINREQUIRE":"非法权限,该帐号无法执行这个操作",
"ERR.PARAMNULL":"系统发生错误:参数为空",
"ERR.ERR.PARAMTOOLONG":"参数过长",
"ERR.ILLEGAL":"系统非法操作"。
                    前言spring boot 2.0.0.RELEASE网易企业邮箱 2019年版jdk 1.8发邮件的说明按照加密方式方式,可以分为:明文TLS加密SSL加密发送明文发送明文邮件时,需要设置好:协议(默认是smtp,可不用设置)host端口(默认是25)用户名密码开启身份验证(mail.smtp.auth=true)网易企业邮箱 不再支持明文邮件了。使...
				
我们都知道,在Android中调用其他程序进行相关处理,几乎都是使用的Intent,所以,Email也不例外。 在Android中,调用Email有三种类型的Intent: Intent.ACTION_SENDTO 无附件的发送 Intent.ACTION_SEND 带附件的发送 Intent.ACTION_SEND_MULTIPLE 带有多附件的发送 当然,所谓的调用Email,只是说Email可以接收Intent并做这些事情,可能也有其他的应用程序实现了相关功能,所以在执行的时候,会出现选择框进行选择。 1.使用SENTTO发送 [java] 代码如下: Intent data=new
smtplib.SMTPAuthenticationError: (535, b’5.7.0 ERR.LOGIN.NONSSL’) 在Django中配置163企业邮箱发送邮件,发送邮件时出现该错误。是因为在此之前,使用的邮箱是未使用HTTPS传输,而此次配置的是企业邮箱,全程使用HTTPS传输。 smtplib.SMTPAuthenticationError:(535, b'5.7.0 ERR.LOGIN.NONSSL') 原来的配置信息 """配置邮件服务器""" # 指定邮件后端 EMAIL_BAC
邮件发送认证失败,原因可能如下: (1)使用的账号,密码跟邮箱登陆的账号密码不一致。 (2)客户端授权码没有开启,可在邮箱设置查看客户端授权码,看POP3/SMTP服务和IMAP/SMTP服务是否开启 注意使用的主机名也要查看是否正确,否则会包550 5.7.1 Client does not have permissions to send as this sender 即使用了不存在或没权限的...
Caused by: com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: smtp.163.com, 25; timeout 60000; 问题:JavaMail做邮件发送时,本地(Windows系统)发送邮件正常,发布到Linux系统后,邮件发送报错: org.apache.commons.mail.Em...
Mysql的数据库分出了一个用户,给外部系统的使用,然后该用户在插入数据库A表的时候,发现报错: 1449 : The user specified as a definer ('root'@'%') does not exist。 但是该用户插入B表缺没有任何问题,一开始我以为权限不够,然后查看了用户权限,发现对应的权限都已经赋予了。而且这个错误也很诡异,我明明不是使用root用户连接数据库的。...
有时我们需要通过shp文件在sumo中生成一些道路交通网络。在sumo该版本 是支持shp文件直接导入的,但是直接通过shp文件导入会出现各种各样奇奇怪怪的问题。目前的一个解决思路是将shp文件转换为osm文件,再通过netconvert将osm转换为net.xml。主要是解决了如下两个问题: 将.shp文件格式转换为.osm文件格式 剔除shp文件dbf属性表中的非法tag,替换为osm中的合法tag 解决方案: 将shp文件转换为osm文件格式主要应用了一个软件,JOSM 1> 安装JOSM
要在 Java 中调用 163 邮箱发送邮件,你需要使用 JavaMail API。 首先,你需要在你的 Java 项目中引入 JavaMail API 库。你可以在这里下载它:https://javaee.github.io/javamail/downloads/index.html 然后,你可以使用以下代码来调用 163 邮箱发送邮件: 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 SendMailTLS { public static void main(String[] args) { final String username = "your_email@163.com"; final String password = "your_password"; Properties prop = new Properties(); prop.put("mail.smtp.auth", "true"); prop.put("mail.smtp.starttls.enable", "true"); prop.put("mail.smtp.host", "smtp.163.com"); prop.put("mail.smtp.port", "587"); Session session = Session.getInstance(prop, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("from_email@163.com")); message.setRecipients( Message.RecipientType.TO, InternetAddress.parse("to_email@gmail.com") message.setSubject("Testing Gmail TLS"); message.setText("Dear Mail Crawler," + "\n\n Please do not spam my email!"); Transport.send(message); System.out.println("Done"); } catch (MessagingException e) { e.printStackTrace(); 在上面的代码中,你需要将 `your_email@163.com` 替换为你的 163 邮箱地址,将 `your_password` 替换为你的邮箱密码,并将 `from_email@163.com` 替换为发件人的邮箱地址,将 `to_email@gmail.com` 替换为
城市多少盏灯: 微信小程序有路由监听API,wx.onAppRoute,文档没有说明,但是可以用。在app.js中的onLaunch方法使用。App({ onLaunch: function () { wx.onAppRoute(function (res) { console.log(res); // 在这里可以进行拦截操作 微信小程序全局路由拦截 城市多少盏灯: 微信小程序有一个监听路由API,wx.onAppRoute,官网没有,但是可以用。用这个API更方便。