How to use JavaMail property settings

zhaozj2021-02-16  100

Rel = "" TYPE = "text / css" href = "../../../ stylesheet.css" title = "style">

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 ....................

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 Transport Send Method, But Supplies The NEEDEERNAME 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 DIGEST-MD5 authentication appropriate realm when using;. 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 the new mime type, but you can process the as any.

See Below for the property to enable the 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. Do not 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.

NameTypeDescriptionmail.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 does not 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.fromString 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.localhostString Local host name Defaults to InetAddress.getLocalHost () getHostName... (). Should not normally need to be set if your JDK and your name service are configured properly. mail.smtp.ehloboolean 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 do not fail EHLO properly or do not implement EHLO properly mail.smtp.authbooleanIf true, attempt to authenticate the user using the AUTH command Defaults to false.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.Allow8bitmimeBoolean 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 us "8bit"

encoding if they follow the RFC2045 rules for 8bit text. mail.smtp.sendpartialboolean 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.saslrealmStringThe realm to use with DIGEST-MD5 authentication.mail.smtp.quitwaitboolean If set to true, causes the transport to . wait for the response to the QUIT command If set to false (the default), the QUIT command is sent and the connection is immediately closed (NOTE: The default may change in the next release.). 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 method getTransport to acq UIRE An Appropriate Transport Object.

转载请注明原文地址:https://www.9cbs.com/read-14704.html

New Post(0)