先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新大数据全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip204888 (备注大数据)
正文
//2.2 通过session对象获取Transport对象(需要抛出异常)
Transport transport = session.getTransport();
//2.3 连接服务器(需要抛出异常)
transport.connect("smtp.qq.com","553401298@qq.com","jyyylkflmkyybcif");
//3 发送邮件
//3.1 创建用来发送邮件的对象(需要传入session)
MimeMessage mimeMessage = new MimeMessage(session);
//3.2 创建邮件发送人
mimeMessage.setFrom(new InternetAddress("553401298@qq.com"));
//3.3 创建邮件接收人(可以同时发送给很多人(添加抄送))
mimeMessage.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress("553401298@qq.com")});
//3.4 创建邮件主题
mimeMessage.setSubject("LUCK");
//3.5 创建邮件正文
mimeMessage.setContent("GOOD LUCK","text/html;charset=utf-8");
//3.6 发送邮件
transport.sendMessage(mimeMessage,mimeMessage.getAllRecipients());
//===================================================================
//4 关闭连接
transport.close();
}
}
**运行结果:**
![在这里插入图片描述](https://img-blog.csdnimg.cn/d5d0baf33a694e8fb4973746f992302f.jpeg#pic_center#pic_center)
## 三、发送文本嵌入图片的邮件
**代码实现:**
public class SendImageEmail {
public static void main(String[] args) throws GeneralSecurityException, MessagingException {
//1.准备
Properties properties = new Properties();
properties.setProperty(“mail.host”,“smtp.qq.com”);
properties.setProperty(“mail.transport.protocol”,“smtp”);
properties.setProperty(“mail.smtp.auth”,“true”);
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
properties.put(“mail.smtp.ssl.enable”, “true”);
properties.put(“mail.smtp.ssl.socketFactory”, sf);
//2.连接服务器
Session session = Session.getDefaultInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(“553401298@11.com”, “jyyylkflmkyybcif”);
}
});
session.setDebug(true);
Transport transport = session.getTransport();
//连接服务器
transport.connect(“smtp.qq.com”,“553401298@qq.com”,“jyyylkflmkyybcif”);
//通过方法获取一个MimeMessage
MimeMessage mimeMessage = setImgEmail(session);
//设置发件人和收件人
mimeMessage.setFrom(new InternetAddress(“553401298@qq.com”));
mimeMessage.setRecipients(Message.RecipientType.TO,new InternetAddress[]{new InternetAddress(“553401298@qq.com”)});
//发送邮件
transport.sendMessage(mimeMessage,mimeMessage.getAllRecipients());
//关闭连接
transport.close();
}
public static MimeMessage setImgEmail(Session session) throws MessagingException {
//编写邮件内容
//1.准备图片
MimeBodyPart bodyPart = new MimeBodyPart();
//2.将图片变为数据流
//获取图片数据
FileDataSource fileDataSource = new FileDataSource(“src/resources/timg.jpg”);
//需要一个处理数据流的处理器来处理
DataHandler dataHandler = new DataHandler(fileDataSource);
//把图片数据放到邮件的正文中
bodyPart.setDataHandler(dataHandler);
//给图片设置一个名字
bodyPart.setContentID(“timg.jpg”);
//设置文本内容
MimeBodyPart bodyPart2 = new MimeBodyPart();
//给第二个邮件内容插入图片 通过图片ID插入
bodyPart2.setContent(“I need more space”+“”,“text/html;charset=utf-8”);
//拼接邮件,描述关系
MimeMultipart multipart = new MimeMultipart();
multipart.addBodyPart(bodyPart);
multipart.addBodyPart(bodyPart2);
//描述邮件类型:related表示邮件为内嵌类型 mixed表示邮件为附件类型
multipart.setSubType(“related”);
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.setContent(multipart);
//保存设置
mimeMessage.setSubject(“内嵌式邮件”);
mimeMessage.saveChanges();
return mimeMessage;
}
}
**运行结果:**
![在这里插入图片描述](https://img-blog.csdnimg.cn/ee7dc61efe9448a0be62e5c29f070eeb.jpeg#pic_center#pic_center)
## 四、发送复杂邮件(文本嵌入图片,添加附件)
**代码实现:**
public class SendMail {
public static void main(String[] args) throws MessagingException, GeneralSecurityException {
//1 准备步骤
//1.1 创建一个配置文件保存并读取信息
Properties properties = new Properties();
//1.2 设置邮件服务器(这里使用了QQ邮箱)
properties.setProperty(“mail.host”,“smtp.qq.com”);
//1.3 设置发送使用的协议
properties.setProperty(“mail.transport.protocol”,“smtp”);
//1.4 设置用户是否需要验证
properties.setProperty(“mail.smtp.auth”,“true”);
//1.5 关于QQ邮箱,还要设置SSL加密,加上以下代码即可
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
properties.put(“mail.smtp.ssl.enable”, “true”);
properties.put(“mail.smtp.ssl.socketFactory”, sf);
//2 连接服务器
//2.1 创建session会话对象
Session session = Session.getDefaultInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(“553401298@qq.com”, “jyyylkflmkyybcif”);
}
});
//开启Session的debug模式,这样就可以查看到程序发送Email的运行状态
session.setDebug(true);
//2.2 通过session对象获取Transport对象(需要抛出异常)
Transport transport = session.getTransport();
//2.3 连接服务器(需要抛出异常)
transport.connect(“smtp.qq.com”,“553401298@qq.com”,“jyyylkflmkyybcif”);
//3 发送邮件
//3.1 创建用来发送邮件的对象(需要传入session)
MimeMessage mimeMessage = new MimeMessage(session);
//3.2 创建邮件发送人
mimeMessage.setFrom(new InternetAddress(“553401298@qq.com”));
//3.3 创建邮件接收人(可以同时发送给很多人(添加抄送))
mimeMessage.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress(“553401298@qq.com”)});
//3.4 创建邮件主题
mimeMessage.setSubject(“LUCK”);
//3.5 创建邮件正文
mimeMessage.setContent(“GOOD LUCK”,“text/html;charset=utf-8”);
//3.6 发送邮件
transport.sendMessage(mimeMessage,mimeMessage.getAllRecipients());
//===================================================================
//4 关闭连接
transport.close();
}
}
**运行结果:**
![在这里插入图片描述](https://img-blog.csdnimg.cn/4bd1a615692f46e6aff0c900285ee3d4.jpeg#pic_center#pic_center)
## 五、发送注册提示邮件
**实体类:**
public class User {
//实体类,用来封装用户信息
private String username;
private String password;
private String email;
public User(){
}
public User(String username, String password, String email) {
this.username = username;
this.password = password;
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return “User{” +
“username='” + username + ‘’’ +
“, password='” + password + ‘’’ +
“, email='” + email + ‘’’ +
‘}’;
}
}
**发送邮件工具类:**
public class SendEmail extends Thread{
//工具类,用来发送邮件
//发件邮箱
private String from = “553401298@qq.com”;
//邮箱的用户名
private String username= “553401298@qq.com”;
//邮箱的授权码
private String password = “jyyylkflmkyybcif”;
//邮箱服务器地址
private String host = “smtp.qq.com”;
private User user;
public SendEmail(User user){
this.user=user;
}
@Override
public void run() {
try {
Properties properties = new Properties();
properties.setProperty(“mail.host”,host);
properties.setProperty(“mail.transport.protocol”,“smtp”);
properties.setProperty(“mail.smtp.auth”,“true”);
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
properties.put(“mail.smtp.ssl.enable”, “true”);
properties.put(“mail.smtp.ssl.socketFactory”, sf);
Session session = Session.getDefaultInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
Transport transport = session.getTransport();
transport.connect(host,username,password);
//通过MimeMessage设置邮件详情
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.setFrom(new InternetAddress(from));
mimeMessage.setRecipients(Message.RecipientType.TO, new InternetAddress[]{
new InternetAddress(user.getEmail())});
mimeMessage.setSubject(“注册成功回执”);
mimeMessage.setContent(“您已成功注册,您的用户名为:”+user.getUsername()
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
功注册,您的用户名为:"+user.getUsername()
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注大数据)
[外链图片转存中…(img-sLQwvuuJ-1713344132389)]
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!