javamail - 协议SMTP\IMAP\POP3设置

资料来自:https://www.tutorialspoint.com/javamail_api/index.htm

【SMTP - Simple Mail Transfer Protocol】

NameTypeDescription
mail.smtp.userStringDefault user name for SMTP.
mail.smtp.hostStringThe SMTP server to connect to.
mail.smtp.portintThe SMTP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 25.
mail.smtp.connectiontimeoutintSocket connection timeout value in milliseconds. Default is infinite timeout.
mail.smtp.timeoutintSocket I/O timeout value in milliseconds. Default is infinite timeout.
mail.smtp.fromStringEmail address to use for SMTP MAIL command. This sets the envelope return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
mail.smtp.localhostStringLocal 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.localaddressStringLocal 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.
mail.smtp.localportintLocal port number to bind to when creating the SMTP socket. Defaults to the port number picked by the Socket class.
mail.smtp.ehlobooleanIf false, do not attempt to sign on with the EHLO command. Defaults to true.
mail.smtp.authbooleanIf true, attempt to authenticate the user using the AUTH command. Defaults to false.
mail.smtp.auth.mechanismsStringIf set, lists the authentication mechanisms to consider. 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.
mail.smtp.auth.login.disablebooleanIf true, prevents use of the AUTH LOGIN command. Default is false.
mail.smtp.auth.plain.disablebooleanIf true, prevents use of the AUTH PLAIN command. Default is false.
mail.smtp.auth.digest-md5.disablebooleanIf true, prevents use of the AUTH DIGEST-MD5 command. Default is false.
mail.smtp.auth.ntlm.disablebooleanIf true, prevents use of the AUTH NTLM command. Default is false.
mail.smtp.auth.ntlm.domainStringThe NTLM authentication domain.
mail.smtp.auth.ntlm.flagsintNTLM protocol-specific flags.
mail.smtp.submitterStringThe 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.
mail.smtp.dsn.notifyStringThe NOTIFY option to the RCPT command. Either NEVER, or some combination of SUCCESS, FAILURE, and DELAY (separated by commas).
mail.smtp.dsn.retStringThe RET option to the MAIL command. Either FULL or HDRS.
mail.smtp.sendpartialbooleanIf 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.enablebooleanIf set to true, attempt to use the javax.security.sasl package to choose an authentication mechanism for login. Defaults to false.
mail.smtp.sasl.mechanismsStringA space or comma separated list of SASL mechanism names to try to use.
mail.smtp.sasl.authorizationidStringThe authorization ID to use in the SASL authentication. If not set, the authentication ID (user name) is used.
mail.smtp.sasl.realmStringThe realm to use with DIGEST-MD5 authentication.
mail.smtp.quitwaitbooleanIf 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.reportsuccessbooleanIf set to true, causes the transport to include an SMTPAddressSucceededException for each address that is successful.
mail.smtp.socketFactorySocket FactoryIf set to a class that implements the javax.net.SocketFactory interface, this class will be used to create SMTP sockets.
mail.smtp.socketFactory.classStringIf 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.fallbackbooleanIf 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.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.smtp.ssl.enablebooleanIf 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.checkserveridentitybooleanIf set to true, checks the server identity as specified by RFC 2595. Defaults to false.
mail.smtp.ssl.trustStringIf 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.socketFactorySSL Socket FactoryIf set to a class that extends the javax.net.ssl.SSLSocketFactory class, this class will be used to create SMTP SSL sockets.
mail.smtp.ssl.socketFactory.classStringIf 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.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.smtp.ssl.protocolsstringSpecifies 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.starttls.enablebooleanIf 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. Defaults to false.
mail.smtp.starttls.requiredbooleanIf 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.socks.hoststringSpecifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server.
mail.smtp.socks.portstringSpecifies 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.mailextensionStringExtension string to append to the MAIL command.
mail.smtp.usersetbooleanIf 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.

 

【IMAP - Internet Message Access Protocol】

NameTypeDescription
mail.imap.userStringDefault user name for IMAP.
mail.imap.hostStringThe IMAP server to connect to.
mail.imap.portintThe IMAP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 143.
mail.imap.partialfetchbooleanControls whether the IMAP partial-fetch capability should be used. Defaults to true.
mail.imap.fetchsizeintPartial fetch size in bytes. Defaults to 16K.
mail.imap.ignorebodystructuresizebooleanThe IMAP BODYSTRUCTURE response includes the exact size of each body part. Normally, this size is used to determine how much data to fetch for each body part. Defaults to false.
mail.imap.connectiontimeoutintSocket connection timeout value in milliseconds. Default is infinite timeout.
mail.imap.timeoutintSocket I/O timeout value in milliseconds. Default is infinite timeout.
mail.imap.statuscachetimeoutintTimeout value in milliseconds for cache of STATUS command response. Default is 1000 (1 second). Zero disables cache.
mail.imap.appendbuffersizeintMaximum size of a message to buffer in memory when appending to an IMAP folder.
mail.imap.connectionpoolsizeintMaximum number of available connections in the connection pool. Default is 1.
mail.imap.connectionpooltimeoutintTimeout value in milliseconds for connection pool connections. Default is 45000 (45 seconds).
mail.imap.separatestoreconnectionbooleanFlag to indicate whether to use a dedicated store connection for store commands. Default is false.
mail.imap.auth.login.disablebooleanIf true, prevents use of the non-standard AUTHENTICATE LOGIN command, instead using the plain LOGIN command. Default is false.
mail.imap.auth.plain.disablebooleanIf true, prevents use of the AUTHENTICATE PLAIN command. Default is false.
mail.imap.auth.ntlm.disablebooleanIf true, prevents use of the AUTHENTICATE NTLM command. Default is false.
mail.imap.proxyauth.userStringIf the server supports the PROXYAUTH extension, this property specifies the name of the user to act as. Authenticate to the server using the administrator's credentials. After authentication, the IMAP provider will issue the PROXYAUTH command with the user name specified in this property.
mail.imap.localaddressStringLocal address (host name) to bind to when creating the IMAP socket. Defaults to the address picked by the Socket class.
mail.imap.localportintLocal port number to bind to when creating the IMAP socket. Defaults to the port number picked by the Socket class.
mail.imap.sasl.enablebooleanIf set to true, attempt to use the javax.security.sasl package to choose an authentication mechanism for login. Defaults to false.
mail.imap.sasl.mechanismsStringA space or comma separated list of SASL mechanism names to try to use.
mail.imap.sasl.authorizationidStringThe authorization ID to use in the SASL authentication. If not set, the authentication ID (user name) is used.
mail.imap.sasl.realmStringThe realm to use with SASL authentication mechanisms that require a realm, such as DIGEST-MD5.
mail.imap.auth.ntlm.domainStringThe NTLM authentication domain.
mail.imap.auth.ntlm.flagsintNTLM protocol-specific flags.
mail.imap.socketFactorySocket FactoryIf set to a class that implements the javax.net.SocketFactory interface, this class will be used to create IMAP sockets.
mail.imap.socketFactory.classStringIf set, specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create IMAP sockets.
mail.imap.socketFactory.fallbackbooleanIf 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.imap.socketFactory.portintSpecifies the port to connect to when using the specified socket factory. Default port is used when not set.
mail.imap.ssl.enablebooleanIf set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "imap" protocol and true for the "imaps" protocol.
mail.imap.ssl.checkserveridentitybooleanIf set to true, check the server identity as specified by RFC 2595. Defaults to false.
mail.imap.ssl.trustStringIf 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.imap.ssl.socketFactorySSL Socket FactoryIf set to a class that extends the javax.net.ssl.SSLSocketFactory class, this class will be used to create IMAP SSL sockets.
mail.imap.ssl.socketFactory.classStringIf set, specifies the name of a class that extends the javax.net.ssl.SSLSocketFactory class. This class will be used to create IMAP SSL sockets.
mail.imap.ssl.socketFactory.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.imap.ssl.protocolsstringSpecifies 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.imap.starttls.enablebooleanIf 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. Default is false.
mail.imap.starttls.requiredbooleanIf 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.imap.socks.hoststringSpecifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server.
mail.imap.socks.portstringSpecifies 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.imap.minidletimeintThis property sets the delay in milliseconds. If not set, the default is 10 milliseconds.
mail.imap.enableimapeventsbooleanEnable special IMAP-specific events to be delivered to the Store's ConnectionListener. If true, unsolicited responses received during the Store's idle method will be sent as ConnectionEvents with a type of IMAPStore.RESPONSE. The event's message will be the raw IMAP response string. By default, these events are not sent.
mail.imap.folder.classStringClass name of a subclass of com.sun.mail.imap.IMAPFolder. The subclass can be used to provide support for additional IMAP commands. The subclass must have public constructors of the form public MyIMAPFolder(String fullName, char separator, IMAPStore store, Boolean isNamespace) and public MyIMAPFolder(ListInfo li, IMAPStore store)

 

【POP3 - Post Office Protocol】

NameTypeDescription
mail.pop3.userStringDefault user name for POP3.
mail.pop3.hostStringThe POP3 server to connect to.
mail.pop3.portintThe POP3 server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 110.
mail.pop3.connectiontimeoutintSocket connection timeout value in milliseconds. Default is infinite timeout.
mail.pop3.timeoutintSocket I/O timeout value in milliseconds. Default is infinite timeout.
mail.pop3.rsetbeforequitbooleanSend a POP3 RSET command when closing the folder, before sending the QUIT command. Default is false.
mail.pop3.message.classStringClass name of a subclass of com.sun.mail.pop3.POP3Message. The subclass can be used to handle (for example) non-standard Content-Type headers. The subclass must have a public constructor of the form MyPOP3Message(Folder f, int msgno) throws MessagingException.
mail.pop3.localaddressStringLocal address (host name) to bind to when creating the POP3 socket. Defaults to the address picked by the Socket class.
mail.pop3.localportintLocal port number to bind to when creating the POP3 socket. Defaults to the port number picked by the Socket class.
mail.pop3.apop.enablebooleanIf set to true, use APOP instead of USER/PASS to login to the POP3 server, if the POP3 server supports APOP. APOP sends a digest of the password rather than the clear text password. Defaults to false.
mail.pop3.socketFactorySocket FactoryIf set to a class that implements the javax.net.SocketFactory interface, this class will be used to create POP3 sockets.
mail.pop3.socketFactory.classStringIf set, specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create POP3 sockets.
mail.pop3.socketFactory.fallbackbooleanIf 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.pop3.socketFactory.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
mail.pop3.ssl.enablebooleanIf set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "pop3" protocol and true for the "pop3s" protocol.
mail.pop3.ssl.checkserveridentitybooleanIf set to true, check the server identity as specified by RFC 2595. Defaults to false.
mail.pop3.ssl.trustStringIf 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.pop3.ssl.socketFactorySSL Socket FactoryIf set to a class that extends the javax.net.ssl.SSLSocketFactory class, this class will be used to create POP3 SSL sockets.
mail.pop3.ssl.socketFactory.classStringIf set, specifies the name of a class that extends the javax.net.ssl.SSLSocketFactory class. This class will be used to create POP3 SSL sockets.
mail.pop3.ssl.socketFactory.portintSpecifies the port to connect to when using the specified socket factory. If not set, the default port will be used.
   
   
mail.pop3.ssl.protocolsstringSpecifies 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.pop3.starttls.enablebooleanIf true, enables the use of the STLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. Defaults to false.
mail.pop3.starttls.requiredbooleanIf true, requires the use of the STLS command. If the server doesn't support the STLS command, or the command fails, the connect method will fail. Defaults to false.
mail.pop3.socks.hoststringSpecifies the host name of a SOCKS5 proxy server that will be used for connections to the mail server.
mail.pop3.socks.portstringSpecifies the port number for the SOCKS5 proxy server.
mail.pop3.disabletopbooleanIf set to true, the POP3 TOP command will not be used to fetch message headers. Defaults to false.
mail.pop3.forgettopheadersbooleanIf set to true, the headers that might have been retrieved using the POP3 TOP command will be forgotten and replaced by headers retrieved as part of the POP3 RETR command. Defaults to false.
mail.pop3.filecache.enablebooleanIf set to true, the POP3 provider will cache message data in a temporary file rather than in memory. Messages are only added to the cache when accessing the message content. Message headers are always cached in memory (on demand). The file cache is removed when the folder is closed or the JVM terminates. Defaults to false.
mail.pop3.filecache.dirStringIf the file cache is enabled, this property can be used to override the default directory used by the JDK for temporary files.
mail.pop3.cachewritetobooleanControls the behavior of the writeTo method on a POP3 message object. If set to true, and the message content hasn't yet been cached, and ignoreList is null, the message is cached before being written. Otherwise, the message is streamed directly to the output stream without being cached. Defaults to false.
mail.pop3.keepmessagecontentbooleanIf this property is set to true, a hard reference to the cached content will be kept, preventing the memory from being reused until the folder is closed or the cached content is explicitly invalidated (using the invalidate method). Defaults to false.

转载于:https://www.cnblogs.com/15ho/p/5907174.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值