# javamail **Repository Path**: helloyang/javamail ## Basic Information - **Project Name**: javamail - **Description**: javaMail 发送文本内容和附件 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2015-01-29 - **Last Updated**: 2024-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Java邮件开发学习 =================== 邮件协议 -------------- #邮件协议 1.smtp-->发邮件的协议 2.pop3-->收邮件的协议 3.imap -->可发可收的协议 #邮件服务器名称 smtp.163.com pop3.163.com smtp协议的默认端口是25 pop3协议的默认端口是110 #JavaMail中的核心类_步骤 1.Session --> 可以理解为jdbc中的Connection的作用 2.MimeMessage --> 邮件信息类 3.Transport --> 发送器,用来发送邮件 #获取Session Properties prop = new Properties(); prop.setProperty("mail.host", "smtp.163.com");//设置服务器主机名 prop.setProperty("mail.smtp.auth","true");//设置需要认证 Session session = Session.getInstance(Properties prop, uthenticator auth) Authenticator auth = new Authenticator(){ public PasswordAuthentication getPasswordAuthentication(){ new PasswordAuthentication("firm_yang","jazr932832");//用户名和密码 } } #注意: 需要mail.jar和activation.jar包的支持