关于javaSMTP协议发邮件你必须知道的知识点
1.阅读官方吐槽
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!!!(哈哈哈笑出声)
2.抄个demo练练手
3.阅读rfc822
4.如有必要请阅读RFC 3030
- SMTP协议提供程序支持RFC 3030中定义的CHUNKING扩展。
- 将
mail.smtp.chunksize属性设置为所需的块大小(以字节为单位)。如果服务器支持CHUNKING扩展,则将使用BDAT命令以块大小发送消息。 - 不支持RFC 3030中描述的BINARYMIME扩展。
4.了解以下prop
想当初可谓是,众里寻他千百度。
抄代码的时候有没有想过mail.smtp.host是什么意思?虽然看名字可能知道个大概,但是这个值是从哪来的?
现在你知道了吗?
|
Name |
Type |
Description |
|
mail.smtp.user |
String |
Default user name for SMTP. |
|
mail.smtp.host |
String |
The SMTP server to connect to. |
|
mail.smtp.port |
int |
The SMTP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 25. |
|
mail.smtp.connectiontimeout |
int |
Socket connection timeout value in milliseconds. This timeout is implemented by java.net.Socket. Default is infinite timeout. |
|
mail.smtp.timeout |
int |
Socket read timeout value in milliseconds. This timeout is implemented by java.net.Socket. Default is infinite timeout. |
|
mail.smtp.writetimeout |
int |
Socket write timeout value in milliseconds. This timeout is implemented by using a java.util.concurrent.ScheduledExecutorService per connection that schedules a thread to close the socket if the timeout expires. Thus, the overhead of using this timeout is one thread per connection. Default is infinite timeout. |
|
mail.smtp.from |
String |
Email address to use for SMTP MAIL command. This sets the envelope return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress(). NOTE: mail.smtp.user was previously used for this. |
|
mail.smtp.localhost |
String |
Local host name used in the SMTP HELO or EHLO command. Defaults to InetAddress.getLocalHost().getHostName(). Should not normally need to be set if your JDK and your name service are configured properly. |
|
mail.smtp.localaddress |
String |
Local address (host name) to bind to when creating the SMTP socket. Defaults to the address picked by the Socket class. Should not normally need to be set, but useful with multi-homed hosts where it's important to pick a particular local address to bind to. |
|
mail.smtp.localport |
int |
Local port number to bind to when creating the SMTP socket. Defaults to the port number picked by the Socket class. |
|
mail.smtp.ehlo |
boolean |
If false, do not attempt to sign on with the EHLO command. Defaults to true. Normally failure of the EHLO command will fallback to the HELO command; this property exists only for servers that don't fail EHLO properly or don't implement EHLO properly. |
|
mail.smtp.auth |
boolean |
If true, attempt to authenticate the user using the AUTH command. Defaults to false. |
|
mail.smtp.auth.mechanisms |
String |
If set, lists the authentication mechanisms to consider, and the order in which to consider them. Only mechanisms supported by the server and supported by the current implementation will be used. The default is "LOGIN PLAIN DIGEST-MD5 NTLM", which includes all the authentication mechanisms supported by the current implementation except XOAUTH2. |
|
mail.smtp.auth.login.disable |
boolean |
If true, prevents use of the AUTH LOGIN command. Default is false. |
|
mail.smtp.auth.plain.disable |
boolean |
If true, prevents use of the AUTH PLAIN command. Default is false. |
|
mail.smtp.auth.digest-md5.disable |
boolean |
If true, prevents use of the AUTH DIGEST-MD5 command. Default is false. |
|
mail.smtp.auth.ntlm.disable |
boolean |
If true, prevents use of the AUTH NTLM command. Default is false. |
|
mail.smtp.auth.ntlm.domain |
String |
The NTLM authentication domain. |
|
mail.smtp.auth.ntlm.flags |
int |
NTLM protocol-specific flags. |
|
mail.smtp.auth.xoauth2.disable |
boolean |
If true, prevents use of the AUTHENTICATE XOAUTH2 command. Because the OAuth 2.0 protocol requires a special access token instead of a password, this mechanism is disabled by default. Enable it by explicitly setting this property to "false" or by setting the "mail.smtp.auth.mechanisms" property to "XOAUTH2". |
|
mail.smtp.submitter |
String |
The submitter to use in the AUTH tag in the MAIL FROM command. Typically used by a mail relay to pass along information about the original submitter of the message. See also the setSubmitter method of SMTPMessage. Mail clients typically do not use this. |
|
mail.smtp.dsn.notify |
String |
The NOTIFY option to the RCPT command. Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY (separated by commas). |
|
mail.smtp.dsn.ret |
String |
The RET option to the MAIL command. Either FULL or HDRS. |
|
mail.smtp.allow8bitmime |
boolean |
If set to true, and the server supports the 8BITMIME extension, text parts of messages that use the "quoted-printable" or "base64" encodings are converted to use "8bit" encoding if they follow the RFC2045 rules for 8bit text. |
|
mail.smtp.sendpartial |
boolean |
If set to true, and a message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address. |
|
mail.smtp.sasl.enable |
boolean |
If set to true, attempt to use the javax.security.sasl package to choose an authentication mechanism for login. Defaults to false. |
|
mail.smtp.sasl.mechanisms |
String |
A space or comma separated list of SASL mechanism names to try to use. |
|
mail.smtp.sasl.authorizationid |
String |
The authorization ID to use in the SASL authentication. If not set, the authentication ID (user name) is used. |
|
mail.smtp.sasl.realm |
String |
The realm to use with DIGEST-MD5 authentication. |
|
mail.smtp.sasl.usecanonicalhostname |
boolean |
If set to true, the canonical host name returned by InetAddress.getCanonicalHostName is passed to the SASL mechanism, instead of the host name used to connect. Defaults to false. |
|
mail.smtp.quitwait |
boolean |
If set to false, the QUIT command is sent and the connection is immediately closed. If set to true (the default), causes the transport to wait for the response to the QUIT command. |
|
mail.smtp.reportsuccess |
boolean |
If set to true, causes the transport to include an SMTPAddressSucceededException for each address that is successful. Note also that this will cause a SendFailedException to be thrown from the sendMessage method of SMTPTransport even if all addresses were correct and the message was sent successfully. |
|
mail.smtp.socketFactory |
SocketFactory |
If set to a class that implements the javax.net.SocketFactory interface, this class will be used to create SMTP sockets. Note that this is an instance of a class, not a name, and must be set using the put method, not the setProperty method. |
|
mail.smtp.socketFactory.class |
String |
If set, specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create SMTP sockets. |
|
mail.smtp.socketFactory.fallback |
boolean |
If set to true, failure to create a socket using the specified socket factory class will cause the socket to be created using the java.net.Socket class. Defaults to true. |
|
mail.smtp.socketFactory.port |
int |
Specifies the port to connect to when using the specified socket factory. If not set, the default port will be used. |
|
mail.smtp.ssl.enable |
boolean |
If set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "smtp" protocol and true for the "smtps" protocol. |
|
mail.smtp.ssl.checkserveridentity |
boolean |
If set to true, check the server identity as specified by RFC 2595. These additional checks based on the content of the server's certificate are intended to prevent man-in-the-middle attacks. Defaults to false. |
|
mail.smtp.ssl.trust |
String |
If set, and a socket factory hasn't been specified, enables use of a MailSSLSocketFactory. If set to "*", all hosts are trusted. If set to a whitespace separated list of hosts, those hosts are trusted. Otherwise, trust depends on the certificate the server presents. |
|
mail.smtp.ssl.socketFactory |
SSLSocketFactory |
If set to a class that extends the javax.net.ssl.SSLSocketFactory class, this class will be used to create SMTP SSL sockets. Note that this is an instance of a class, not a name, and must be set using the put method, not the setProperty method. |
|
mail.smtp.ssl.socketFactory.class |
String |
If set, specifies the name of a class that extends the javax.net.ssl.SSLSocketFactory class. This class will be used to create SMTP SSL sockets. |
|
mail.smtp.ssl.socketFactory.port |
int |
Specifies the port to connect to when using the specified socket factory. If not set, the default port will be used. |
|
mail.smtp.ssl.protocols |
string |
Specifies the SSL protocols that will be enabled for SSL connections. The property value is a whitespace separated list of tokens acceptable to the javax.net.ssl.SSLSocket.setEnabledProtocols method. |
|
mail.smtp.ssl.ciphersuites |
string |
Specifies the SSL cipher suites that will be enabled for SSL connections. The property value is a whitespace separated list of tokens acceptable to the javax.net.ssl.SSLSocket.setEnabledCipherSuites method. |
|
mail.smtp.starttls.enable |
boolean |
If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. If the server does not support STARTTLS, the connection continues without the use of TLS; see the mail.smtp.starttls.required property to fail if STARTTLS isn't supported. Note that an appropriate trust store must configured so that the client will trust the server's certificate. Defaults to false. |
|
mail.smtp.starttls.required |
boolean |
If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, or the command fails, the connect method will fail. Defaults to false. |
|
mail.smtp.proxy.host |
string |
Specifies the host name of an HTTP web proxy server that will be used for connections to the mail server. |
|
mail.smtp.proxy.port |
string |
Specifies the port number for the HTTP web proxy server. Defaults to port 80. |
|
mail.smtp.proxy.user |
string |
Specifies the user name to use to authenticate with the HTTP web proxy server. By default, no authentication is done. |
|
mail.smtp.proxy.password |
string |
Specifies the password to use to authenticate with the HTTP web proxy server. By default, no authentication is done. |
|
mail.smtp.socks.host |
string |
Specifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server. |
|
mail.smtp.socks.port |
string |
Specifies the port number for the SOCKS5 proxy server. This should only need to be used if the proxy server is not using the standard port number of 1080. |
|
mail.smtp.mailextension |
String |
Extension string to append to the MAIL command. The extension string can be used to specify standard SMTP service extensions as well as vendor-specific extensions. Typically the application should use the SMTPTransport method supportsExtension to verify that the server supports the desired service extension. See RFC 1869 and other RFCs that define specific extensions. |
|
mail.smtp.userset |
boolean |
If set to true, use the RSET command instead of the NOOP command in the isConnected method. In some cases sendmail will respond slowly after many NOOP commands; use of RSET avoids this sendmail issue. Defaults to false. |
|
mail.smtp.noop.strict |
boolean |
If set to true (the default), insist on a 250 response code from the NOOP command to indicate success. The NOOP command is used by the isConnected method to determine if the connection is still alive. Some older servers return the wrong response code on success, some servers don't implement the NOOP command at all and so always return a failure code. Set this property to false to handle servers that are broken in this way. Normally, when a server times out a connection, it will send a 421 response code, which the client will see as the response to the next command it issues. Some servers send the wrong failure response code when timing out a connection. Do not set this property to false when dealing with servers that are broken in this way. |
关于javaSMTP协议发邮件你必须知道的知识点的更多相关文章
- 依据 smtp协议的简单golang 的发邮件实现
依据 smtp协议的简单golang 的发邮件实现 协议格式如下 From:sender_user@demo.net To:to_user@demo.net Subject:这是主题 Mime-Ver ...
- POP3是收邮件的协议,SMTP是发邮件的协议,IMAP是一种邮箱通信协议。
我也是第一次接触这种服务,是因为我自己在做一个小小的自动推送天气情况到自己邮箱.所以才碰到这个的/ 看一下标题,我们可以先这样理解. POP3(Post Office Protocol - Versi ...
- php 发邮件的2种方式(使用stmp类、使用socket协议)
方式1:使用stmp类发送邮件 代码: stmp.php <?php header("Content-Type: text/html; charset=utf-8"); cl ...
- centos 邮件服务 腾讯企业邮箱(免费) 使用iRedmail 需要有公网的centos主机 发邮件协议:smtp 端口25 收邮件协议:pop3 端口110 iredmail安装配置 使用邮箱系统 第三十一节课
centos 邮件服务 腾讯企业邮箱(免费) 使用iRedmail 需要有公网的centos主机 发邮件协议:smtp 端口25 收邮件协议:pop3 端口110 iredmail安装配置 ...
- 打电话,发短信,发邮件,app跳转
1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...
- iOS中如何切换到发短信、打电话、发邮件
我们在做APP的时候,难免会遇到需要调用短信,电话等程序的时候.如美团. 当然,这些都只是一些简单的方法就可以实现,但是时间久了也会淡忘,所以想写这边博客.一是为了再捡起来复习一下,另一个相当于留个备 ...
- C#后台程序重启IIS,发邮件通知
应用场景:IIS网站挂掉,系统自动重启IIS,通知相关联系人: 主要代码: 监控类 public class monitoringiis { EmailSend send = new EmailSen ...
- PHP实例开发(2)PHP通过mail()或Socket发邮件
PHP通过mail()或Socket发邮件 1.PHP中发送邮件的方法 PHP发送邮件是“非常的简单” 因为他提供了mail()函数直接发送,但这也继 register globals 成为了对初学者 ...
- EDM营销算法:python自动批量发邮件
EDM营销:全称Email Direct Marketing,即电子邮件营销.企业可以通过使用EDM软件向目标客户发送EDM邮件,建立同目标顾客的沟通渠道,向其直接传达相关信息,用来促进销售.EDM软 ...
随机推荐
- Vue3教程:一个基于 Vue 3 + Vant 3 的商城项目开源啦!
之前发布过一篇文章,告诉大家我要开发一个 Vue3 的商城项目并开源到 GitHub 上,供大家练手和学习,随后也一直有收到留言和反馈,问我开发到哪里了,什么时候开源之类的问题,今天终于可以通知大家, ...
- 跟我一起学.NetCore之EF Core 实战入门,一看就会
前言 还记得当初学习数据库操作时,用ADO.NET一步一步地进行数据操作及查询,对于查询到的数据还得对其进行解析,然后封装返回给应用层:遇到这种重复而繁琐的工作,总有一些大神或团队对其进行封装,从而出 ...
- 14、Cookie和Session组件
cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不 ...
- 17、ContentType组件
一 项目背景 路飞学成项目,有课程,学位课(不同的课程字段不一样),价格策略 问题: 1 如何设计表结构,来表示这种规则 2 为专题课,添加三个价格策略 3 查询所有价格策略,并且显示对应 ...
- Java8 新特性 —— 函数式编程
本文部分摘录自 On Java 8 概述 通常,传递给方法的数据不同,结果也不同.同样的,如果我们希望方法被调用时的行为不同,该怎么做呢?结论是:只要能将代码传递给方法,那么就可以控制方法的行为. 说 ...
- jenkins配置邮件报错:501 mail from address must be same as authorization user
jenkins配置文件的时候,遇到如下报错: 我的配置是这样的: 最后发现是jenkins url下面的系统管理员邮件地址没写,填写与用户名一致就可以了.
- 无需开发,IT事件接入钉钉的方法详解
1.市场在拥抱钉钉 虎嗅8月30日发表了一篇文章<为什么有很多企业沉迷钉钉无法自拔>,有兴趣的可以去看看,下附文章链接. 文章不短,其中有一部分阐述了:钉钉抓住以人为核心的"智能 ...
- 设计模式(一)--工厂模式(Go实现)
package Factory import "fmt" type Restaurant interface { GetFood() } type Donglaishun stru ...
- dpkg 批量卸载
dpkg -l |grep deepin|awk '{print $2}'|xargs sudo dpkg -P
- HttpClient4.3 连接池参数配置及源码解读
目前所在公司使用HttpClient 4.3.3版本发送Rest请求,调用接口.最近出现了调用查询接口服务慢的生产问题,在排查整个调用链可能存在的问题时(从客户端发起Http请求->ESB-&g ...