最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
发邮件时终于可以通过sina的smtp验证了(附代码)
时间:2022-07-02 18:11:52 编辑:袖梨 来源:一聚教程网
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class sendMail
{
public static void main(String args[]) throws Exception
{
String host = "smtp.sina.com.cn";
String from = "[email protected]";
String to = "[email protected]";
String username = "javamail";
String password = "password";
// Get system properties
// Properties props = System.getProperties(); 很多例子中是这样的,其实下面这句更好,可以用在applet中
Properties props = new Properties();
// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true"); //这样才能通过验证
// Get session
Session session = Session.getDefaultInstance(props);
// watch the mail commands go by to the mail server
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
import javax.mail.internet.*;
import java.util.*;
public class sendMail
{
public static void main(String args[]) throws Exception
{
String host = "smtp.sina.com.cn";
String from = "[email protected]";
String to = "[email protected]";
String username = "javamail";
String password = "password";
// Get system properties
// Properties props = System.getProperties(); 很多例子中是这样的,其实下面这句更好,可以用在applet中
Properties props = new Properties();
// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true"); //这样才能通过验证
// Get session
Session session = Session.getDefaultInstance(props);
// watch the mail commands go by to the mail server
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
相关文章
- 华夏绘世录平民火队怎么搭配 平民火队配队攻略 09-17
- 逆战未来怎么快速刷金币-逆战未来金币快速获取方法介绍 09-17
- 猎风传说武器升级怎么升级-猎风传说武器升级升级玩法分享 09-17
- 无主之地4通关后快速刷经验方法 怎么快速升级 09-17
- 阴阳师妙主九命猫御魂怎么搭配-SP妙主九命猫御魂搭配推荐 09-17
- 为了吾王僧侣怎么获取 09-17