阿里云邮件推送服务-接口说明-D

阿里云邮件推送服务-接口说明-D

ID:36204874

大小:136.86 KB

页数:8页

时间:2019-05-07

阿里云邮件推送服务-接口说明-D_第1页
阿里云邮件推送服务-接口说明-D_第2页
阿里云邮件推送服务-接口说明-D_第3页
阿里云邮件推送服务-接口说明-D_第4页
阿里云邮件推送服务-接口说明-D_第5页
资源描述:

《阿里云邮件推送服务-接口说明-D》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、邮件推送SMTP接口说明邮件推送/SMTP接口说明SMTP接口说明SMTP服务地址SMTP服务地址:smtpdm.aliyun.comSMTP端口号:25,465(SSL加密)importjavax.mail.*;importjavax.mail.internet.InternetAddress;importjavax.mail.internet.MimeMessage;importjava.util.Properties;publicclassSimpleAliDMSendMail{privatestaticfinalStringALIDM_SMTP_HO

2、ST="smtpdm.aliyun.com";privatestaticfinalintALIDM_SMTP_PORT=25;publicstaticvoidmain(String[]args)throwsMessagingException{//配置发送邮件的环境属性finalPropertiesprops=newProperties();//表示SMTP发送邮件,需要进行身份验证props.put("mail.smtp.auth","true");props.put("mail.smtp.host",ALIDM_SMTP_HOST);props.put(

3、"mail.smtp.port",ALIDM_SMTP_PORT);//如果使用ssl,则去掉使用25端口的配置,进行如下配置,//props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");//props.put("mail.smtp.socketFactory.port","465");//props.put("mail.smtp.port","465");//发件人的账号props.put("mail.user","***");//访问SMTP服务时需要提供的密

4、码props.put("mail.password","***");//构建授权信息,用于进行SMTP进行身份验证Authenticatorauthenticator=newAuthenticator(){@OverrideprotectedPasswordAuthenticationgetPasswordAuthentication(){//用户名、密码StringuserName=props.getProperty("mail.user");Stringpassword=props.getProperty("mail.password");使用javam

5、ail通过smtp协议发信7邮件推送/SMTP接口说明returnnewPasswordAuthentication(userName,password);}};//使用环境属性和授权信息,创建邮件会话SessionmailSession=Session.getInstance(props,authenticator);//创建邮件消息MimeMessagemessage=newMimeMessage(mailSession);//设置发件人InternetAddressform=newInternetAddress(props.getProperty("m

6、ail.user"));message.setFrom(form);//设置收件人InternetAddressto=newInternetAddress("***");message.setRecipient(MimeMessage.RecipientType.TO,to);//设置邮件标题message.setSubject("测试邮件");//设置邮件的内容体message.setContent("测试的HTML邮件","text/html;charset=UTF-8");//发送邮件Transport.send(message);}}usingSys

7、tem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Net.Mail;usingSystem.Net.Mime;namespaceConsoleApp{classProgram{staticvoidMain(string[]args){try{MailMessagemailMsg=newMailMessage();mailMsg.To.Add(newMailAddress("目标地址"));mailMsg.From=newMailAddress("控制台创建的发信地址","昵称")

8、;//邮件主题mailMsg.Subject="邮件

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。