牙叔教程 简单易懂
修改三个地方
- from 发件人的谷歌邮箱
- password 发件人的谷歌邮箱密码
- to 收件人邮箱
importClass(java.util.Properties); importClass(javax.mail.Message); importClass(javax.mail.MessagingException); importClass(javax.mail.PasswordAuthentication); importClass(javax.mail.Session); importClass(javax.mail.Transport); importClass(javax.mail.internet.InternetAddress); importClass(javax.mail.internet.MimeMessage); from = "xxx@gmail.com"; password = "xxx"; to = "xxxxxx@qq.com"; host = "smtp.gmail.com"; properties = java.lang.System.getProperties(); properties.put("mail.smtp.host", host); properties.put("mail.smtp.port", "465"); properties.put("mail.smtp.ssl.enable", "true"); properties.put("mail.smtp.auth", "true"); session = Session.getInstance( properties, new javax.mail.Authenticator({ getPasswordAuthentication: function () { return new PasswordAuthentication(from, password); }, }) ); session.setDebug(true); message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("This is the Subject Line!"); message.setText("This is actual message"); log("sending..."); Transport.send(message); log("Sent message successfully....");
备注
网络问题, 科学上网, 不然timeout
测试环境
手机: Mi 11 Pro
Android版本: 12
Autojs版本: 9.1.14
名人名言
思路是最重要的, 其他的百度, bing, stackoverflow, github, 安卓文档, autojs文档, 最后才是群里问问 --- 牙叔教程
声明
部分内容来自网络 本教程仅用于学习, 禁止用于其他用途