有关使用javamail发信的设置
来源:互联网 发布:淘宝网店模板下载 编辑:程序博客网 时间:2024/05/01 13:13
有关使用javamail发信的设置。
An SMTP protocol provider for the JavaMail API that provides access to an SMTP server. Refer to RFC 821 for more information.
The SMTP provider also supports ESMTP (RFC 1651). It can optionally use SMTP Authentication (RFC 2554) using the LOGIN, PLAIN, and DIGEST-MD5 mechanisms (RFC 2592 and RFC 2831).
To use SMTP authentication you’ll need to provide the SMTP Transport with a username and password when connecting to the SMTP server. You can do this using one of the following approaches:
- Provide an Authenticator object when creating your mail Session and provide the username and password information during the Authenticator callback.
Note that the
mail.smtp.user
property can be set to provide a default username for the callback, but the password will still need to be supplied explicitly.This approach allows you to use the static Transport
send
method to send messages. - Call the Transport
connect
method explicitly with username and password arguments.This approach requires you to explicitly manage a Transport object and use the Transport
sendMessage
method to send the message. The transport.java demo program demonstrates how to manage a Transport object. The following is roughly equivalent to the static Transportsend
method, but supplies the needed username and password:Transport tr = session.getTransport("smtp"); tr.connect(smtphost, username, password); msg.saveChanges();
// don’t forget this tr.sendMessage(msg, msg.getAllRecipients()); tr.close();
You’ll also need to supply an appropriate realm when using DIGEST-MD5 authentication; your mail server administrator can supply this information. You can set this using the mail.smtp.saslrealm
property, or the setSASLRealm
method on SMTPTransport
.
SMTP can also optionally request Delivery Status Notifications (RFC 1891). The delivery status will typically be reported using a "multipart/report" (RFC 1892) message type with a "message/delivery-status" (RFC 1894) part. JavaMail does not currently provide direct support for these new MIME types, but you can process them as any other "multipart" or "message" content, using MimeMultipart
and MimeMessage
objects.
See below for the properties to enable these features.
Note also that THERE IS NOT SUFFICIENT DOCUMENTATION HERE TO USE THESE FEATURES!!! You will need to read the appropriate RFCs mentioned above to understand what these features do and how to use them. Don’t just start setting properties and then complain to us when it doesn’t work like you expect it to work. READ THE RFCs FIRST!!!
The SMTP protocol provider supports the following properties, which may be set in the JavaMail Session
object. The properties are always set as strings; the Type column describes how the string is interpreted. For example, use
props.put("mail.smtp.port", "888");to set the
mail.smtp.port
property, which is of type int.
In general, applications should not need to use the classes in this package directly. Instead, they should use the APIs defined by javax.mail
package (and subpackages). Applications should never construct instances of SMTPTransport
directly. Instead, they should use the Session
- 有关使用javamail发信的设置
- JavaMail 使用发信身份验证
- javamail中使用发信身份验证
- javamail发信带附件的问题
- java邮件发送的简单实现,使用javamail通过smtp协议发信
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题…
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题及解决方法(转)
- 使用javamail发信过程中的一些问题及解决方法
- 使用javamail发信过程中的一些问题…
- 使用javamail发信过程中的一些问题及解决方法
- javamail中的STARTTLS验证需要证书时的发信
- 怎样使用javamail的属性设置
- 用javamail进行认证发信
- effective stl读书笔记 —— Item 4
- 因版权问题暂停翻译“每个家庭都有一个机器人”
- C#实现网络包监视
- Shifting
- 常用的SQL语句
- 有关使用javamail发信的设置
- BI应用,使用开源的还是商业的?
- SQL几个小函数
- 优秀IT建筑师(Architect)之路
- 时尚的法老—图坦卡门
- SQL SERVER 数据库链接服务器总结
- http://my.donews.com/flymeteor/tag/network/
- 关闭135和445端口。
- 深入理解Symbian控件架构