From 44a796ed57e87a386cf212d6e750343faf9affdc Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 14 四月 2023 14:20:57 +0800 Subject: [PATCH] update 优化 邮件工具代码格式 --- ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java | 1140 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 570 insertions(+), 570 deletions(-) diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java index d2b9e2c..2a732a1 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java @@ -18,642 +18,642 @@ * @author Luxiaolei */ public class MailAccount implements Serializable { - @Serial + @Serial private static final long serialVersionUID = -6937313421815719204L; - private static final String MAIL_PROTOCOL = "mail.transport.protocol"; - private static final String SMTP_HOST = "mail.smtp.host"; - private static final String SMTP_PORT = "mail.smtp.port"; - private static final String SMTP_AUTH = "mail.smtp.auth"; - private static final String SMTP_TIMEOUT = "mail.smtp.timeout"; - private static final String SMTP_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout"; - private static final String SMTP_WRITE_TIMEOUT = "mail.smtp.writetimeout"; + private static final String MAIL_PROTOCOL = "mail.transport.protocol"; + private static final String SMTP_HOST = "mail.smtp.host"; + private static final String SMTP_PORT = "mail.smtp.port"; + private static final String SMTP_AUTH = "mail.smtp.auth"; + private static final String SMTP_TIMEOUT = "mail.smtp.timeout"; + private static final String SMTP_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout"; + private static final String SMTP_WRITE_TIMEOUT = "mail.smtp.writetimeout"; - // SSL - private static final String STARTTLS_ENABLE = "mail.smtp.starttls.enable"; - private static final String SSL_ENABLE = "mail.smtp.ssl.enable"; - private static final String SSL_PROTOCOLS = "mail.smtp.ssl.protocols"; - private static final String SOCKET_FACTORY = "mail.smtp.socketFactory.class"; - private static final String SOCKET_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; - private static final String SOCKET_FACTORY_PORT = "smtp.socketFactory.port"; + // SSL + private static final String STARTTLS_ENABLE = "mail.smtp.starttls.enable"; + private static final String SSL_ENABLE = "mail.smtp.ssl.enable"; + private static final String SSL_PROTOCOLS = "mail.smtp.ssl.protocols"; + private static final String SOCKET_FACTORY = "mail.smtp.socketFactory.class"; + private static final String SOCKET_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; + private static final String SOCKET_FACTORY_PORT = "smtp.socketFactory.port"; - // System Properties - private static final String SPLIT_LONG_PARAMS = "mail.mime.splitlongparameters"; - //private static final String ENCODE_FILE_NAME = "mail.mime.encodefilename"; - //private static final String CHARSET = "mail.mime.charset"; + // System Properties + private static final String SPLIT_LONG_PARAMS = "mail.mime.splitlongparameters"; + //private static final String ENCODE_FILE_NAME = "mail.mime.encodefilename"; + //private static final String CHARSET = "mail.mime.charset"; - // 鍏朵粬 - private static final String MAIL_DEBUG = "mail.debug"; + // 鍏朵粬 + private static final String MAIL_DEBUG = "mail.debug"; - public static final String[] MAIL_SETTING_PATHS = new String[]{"config/mail.setting", "config/mailAccount.setting", "mail.setting"}; + public static final String[] MAIL_SETTING_PATHS = new String[]{"config/mail.setting", "config/mailAccount.setting", "mail.setting"}; - /** - * SMTP鏈嶅姟鍣ㄥ煙鍚� - */ - private String host; - /** - * SMTP鏈嶅姟绔彛 - */ - private Integer port; - /** - * 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 - */ - private Boolean auth; - /** - * 鐢ㄦ埛鍚� - */ - private String user; - /** - * 瀵嗙爜 - */ - private String pass; - /** - * 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 - */ - private String from; + /** + * SMTP鏈嶅姟鍣ㄥ煙鍚� + */ + private String host; + /** + * SMTP鏈嶅姟绔彛 + */ + private Integer port; + /** + * 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 + */ + private Boolean auth; + /** + * 鐢ㄦ埛鍚� + */ + private String user; + /** + * 瀵嗙爜 + */ + private String pass; + /** + * 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 + */ + private String from; - /** - * 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� - */ - private boolean debug; - /** - * 缂栫爜鐢ㄤ簬缂栫爜閭欢姝f枃鍜屽彂閫佷汉銆佹敹浠朵汉绛変腑鏂� - */ - private Charset charset = CharsetUtil.CHARSET_UTF_8; - /** - * 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛� - */ - private boolean splitlongparameters = false; - /** - * 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} - */ - private boolean encodefilename = true; + /** + * 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� + */ + private boolean debug; + /** + * 缂栫爜鐢ㄤ簬缂栫爜閭欢姝f枃鍜屽彂閫佷汉銆佹敹浠朵汉绛変腑鏂� + */ + private Charset charset = CharsetUtil.CHARSET_UTF_8; + /** + * 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛� + */ + private boolean splitlongparameters = false; + /** + * 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} + */ + private boolean encodefilename = true; - /** - * 浣跨敤 STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� - */ - private boolean starttlsEnable = false; - /** - * 浣跨敤 SSL瀹夊叏杩炴帴 - */ - private Boolean sslEnable; + /** + * 浣跨敤 STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� + */ + private boolean starttlsEnable = false; + /** + * 浣跨敤 SSL瀹夊叏杩炴帴 + */ + private Boolean sslEnable; - /** - * SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 - */ - private String sslProtocols; + /** + * SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 + */ + private String sslProtocols; - /** - * 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 - */ - private String socketFactoryClass = "javax.net.ssl.SSLSocketFactory"; - /** - * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true - */ - private boolean socketFactoryFallback; - /** - * 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� - */ - private int socketFactoryPort = 465; + /** + * 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 + */ + private String socketFactoryClass = "javax.net.ssl.SSLSocketFactory"; + /** + * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true + */ + private boolean socketFactoryFallback; + /** + * 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� + */ + private int socketFactoryPort = 465; - /** - * SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 - */ - private long timeout; - /** - * Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - */ - private long connectionTimeout; - /** - * Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - */ - private long writeTimeout; + /** + * SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 + */ + private long timeout; + /** + * Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + */ + private long connectionTimeout; + /** + * Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + */ + private long writeTimeout; - /** - * 鑷畾涔夌殑鍏朵粬灞炴�э紝姝よ嚜瀹氫箟灞炴�т細瑕嗙洊榛樿灞炴�� - */ - private final Map<String, Object> customProperty = new HashMap<>(); + /** + * 鑷畾涔夌殑鍏朵粬灞炴�э紝姝よ嚜瀹氫箟灞炴�т細瑕嗙洊榛樿灞炴�� + */ + private final Map<String, Object> customProperty = new HashMap<>(); - // -------------------------------------------------------------- Constructor start + // -------------------------------------------------------------- Constructor start - /** - * 鏋勯��,鎵�鏈夊弬鏁伴渶鑷瀹氫箟鎴栦繚鎸侀粯璁ゅ�� - */ - public MailAccount() { - } + /** + * 鏋勯��,鎵�鏈夊弬鏁伴渶鑷瀹氫箟鎴栦繚鎸侀粯璁ゅ�� + */ + public MailAccount() { + } - /** - * 鏋勯�� - * - * @param settingPath 閰嶇疆鏂囦欢璺緞 - */ - public MailAccount(String settingPath) { - this(new Setting(settingPath)); - } + /** + * 鏋勯�� + * + * @param settingPath 閰嶇疆鏂囦欢璺緞 + */ + public MailAccount(String settingPath) { + this(new Setting(settingPath)); + } - /** - * 鏋勯�� - * - * @param setting 閰嶇疆鏂囦欢 - */ - public MailAccount(Setting setting) { - setting.toBean(this); - } + /** + * 鏋勯�� + * + * @param setting 閰嶇疆鏂囦欢 + */ + public MailAccount(Setting setting) { + setting.toBean(this); + } - // -------------------------------------------------------------- Constructor end + // -------------------------------------------------------------- Constructor end - /** - * 鑾峰緱SMTP鏈嶅姟鍣ㄥ煙鍚� - * - * @return SMTP鏈嶅姟鍣ㄥ煙鍚� - */ - public String getHost() { - return host; - } + /** + * 鑾峰緱SMTP鏈嶅姟鍣ㄥ煙鍚� + * + * @return SMTP鏈嶅姟鍣ㄥ煙鍚� + */ + public String getHost() { + return host; + } - /** - * 璁剧疆SMTP鏈嶅姟鍣ㄥ煙鍚� - * - * @param host SMTP鏈嶅姟鍣ㄥ煙鍚� - * @return this - */ - public MailAccount setHost(String host) { - this.host = host; - return this; - } + /** + * 璁剧疆SMTP鏈嶅姟鍣ㄥ煙鍚� + * + * @param host SMTP鏈嶅姟鍣ㄥ煙鍚� + * @return this + */ + public MailAccount setHost(String host) { + this.host = host; + return this; + } - /** - * 鑾峰緱SMTP鏈嶅姟绔彛 - * - * @return SMTP鏈嶅姟绔彛 - */ - public Integer getPort() { - return port; - } + /** + * 鑾峰緱SMTP鏈嶅姟绔彛 + * + * @return SMTP鏈嶅姟绔彛 + */ + public Integer getPort() { + return port; + } - /** - * 璁剧疆SMTP鏈嶅姟绔彛 - * - * @param port SMTP鏈嶅姟绔彛 - * @return this - */ - public MailAccount setPort(Integer port) { - this.port = port; - return this; - } + /** + * 璁剧疆SMTP鏈嶅姟绔彛 + * + * @param port SMTP鏈嶅姟绔彛 + * @return this + */ + public MailAccount setPort(Integer port) { + this.port = port; + return this; + } - /** - * 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 - * - * @return 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 - */ - public Boolean isAuth() { - return auth; - } + /** + * 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 + * + * @return 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 + */ + public Boolean isAuth() { + return auth; + } - /** - * 璁剧疆鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 - * - * @param isAuth 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 - * @return this - */ - public MailAccount setAuth(boolean isAuth) { - this.auth = isAuth; - return this; - } + /** + * 璁剧疆鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 + * + * @param isAuth 鏄惁闇�瑕佺敤鎴峰悕瀵嗙爜楠岃瘉 + * @return this + */ + public MailAccount setAuth(boolean isAuth) { + this.auth = isAuth; + return this; + } - /** - * 鑾峰彇鐢ㄦ埛鍚� - * - * @return 鐢ㄦ埛鍚� - */ - public String getUser() { - return user; - } + /** + * 鑾峰彇鐢ㄦ埛鍚� + * + * @return 鐢ㄦ埛鍚� + */ + public String getUser() { + return user; + } - /** - * 璁剧疆鐢ㄦ埛鍚� - * - * @param user 鐢ㄦ埛鍚� - * @return this - */ - public MailAccount setUser(String user) { - this.user = user; - return this; - } + /** + * 璁剧疆鐢ㄦ埛鍚� + * + * @param user 鐢ㄦ埛鍚� + * @return this + */ + public MailAccount setUser(String user) { + this.user = user; + return this; + } - /** - * 鑾峰彇瀵嗙爜 - * - * @return 瀵嗙爜 - */ - public String getPass() { - return pass; - } + /** + * 鑾峰彇瀵嗙爜 + * + * @return 瀵嗙爜 + */ + public String getPass() { + return pass; + } - /** - * 璁剧疆瀵嗙爜 - * - * @param pass 瀵嗙爜 - * @return this - */ - public MailAccount setPass(String pass) { - this.pass = pass; - return this; - } + /** + * 璁剧疆瀵嗙爜 + * + * @param pass 瀵嗙爜 + * @return this + */ + public MailAccount setPass(String pass) { + this.pass = pass; + return this; + } - /** - * 鑾峰彇鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 - * - * @return 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 - */ - public String getFrom() { - return from; - } + /** + * 鑾峰彇鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 + * + * @return 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 + */ + public String getFrom() { + return from; + } - /** - * 璁剧疆鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯<br> - * 鍙戜欢浜哄彲浠ユ槸浠ヤ笅褰㈠紡锛� - * - * <pre> - * 1. user@xxx.xx - * 2. name <user@xxx.xx> - * </pre> - * - * @param from 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 - * @return this - */ - public MailAccount setFrom(String from) { - this.from = from; - return this; - } + /** + * 璁剧疆鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯<br> + * 鍙戜欢浜哄彲浠ユ槸浠ヤ笅褰㈠紡锛� + * + * <pre> + * 1. user@xxx.xx + * 2. name <user@xxx.xx> + * </pre> + * + * @param from 鍙戦�佹柟锛岄伒寰猂FC-822鏍囧噯 + * @return this + */ + public MailAccount setFrom(String from) { + this.from = from; + return this; + } - /** - * 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� - * - * @return 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� - * @since 4.0.2 - */ - public boolean isDebug() { - return debug; - } + /** + * 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� + * + * @return 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� + * @since 4.0.2 + */ + public boolean isDebug() { + return debug; + } - /** - * 璁剧疆鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� - * - * @param debug 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� - * @return this - * @since 4.0.2 - */ - public MailAccount setDebug(boolean debug) { - this.debug = debug; - return this; - } + /** + * 璁剧疆鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� + * + * @param debug 鏄惁鎵撳紑璋冭瘯妯″紡锛岃皟璇曟ā寮忎細鏄剧ず涓庨偖浠舵湇鍔″櫒閫氫俊杩囩▼锛岄粯璁や笉寮�鍚� + * @return this + * @since 4.0.2 + */ + public MailAccount setDebug(boolean debug) { + this.debug = debug; + return this; + } - /** - * 鑾峰彇瀛楃闆嗙紪鐮� - * - * @return 缂栫爜锛屽彲鑳戒负{@code null} - */ - public Charset getCharset() { - return charset; - } + /** + * 鑾峰彇瀛楃闆嗙紪鐮� + * + * @return 缂栫爜锛屽彲鑳戒负{@code null} + */ + public Charset getCharset() { + return charset; + } - /** - * 璁剧疆瀛楃闆嗙紪鐮侊紝姝ら�夐」涓嶄細淇敼鍏ㄥ眬閰嶇疆锛岃嫢淇敼鍏ㄥ眬閰嶇疆锛岃璁剧疆姝ら」涓簕@code null}骞惰缃細 - * <pre> - * System.setProperty("mail.mime.charset", charset); - * </pre> - * - * @param charset 瀛楃闆嗙紪鐮侊紝{@code null} 鍒欒〃绀轰娇鐢ㄥ叏灞�璁剧疆鐨勯粯璁ょ紪鐮侊紝鍏ㄥ眬缂栫爜涓簃ail.mime.charset绯荤粺灞炴�� - * @return this - */ - public MailAccount setCharset(Charset charset) { - this.charset = charset; - return this; - } + /** + * 璁剧疆瀛楃闆嗙紪鐮侊紝姝ら�夐」涓嶄細淇敼鍏ㄥ眬閰嶇疆锛岃嫢淇敼鍏ㄥ眬閰嶇疆锛岃璁剧疆姝ら」涓簕@code null}骞惰缃細 + * <pre> + * System.setProperty("mail.mime.charset", charset); + * </pre> + * + * @param charset 瀛楃闆嗙紪鐮侊紝{@code null} 鍒欒〃绀轰娇鐢ㄥ叏灞�璁剧疆鐨勯粯璁ょ紪鐮侊紝鍏ㄥ眬缂栫爜涓簃ail.mime.charset绯荤粺灞炴�� + * @return this + */ + public MailAccount setCharset(Charset charset) { + this.charset = charset; + return this; + } - /** - * 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛� - * - * @return 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠� - */ - public boolean isSplitlongparameters() { - return splitlongparameters; - } + /** + * 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛� + * + * @return 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠� + */ + public boolean isSplitlongparameters() { + return splitlongparameters; + } - /** - * 璁剧疆瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛�<br> - * 娉ㄦ剰姝ら」涓哄叏灞�璁剧疆锛屾椤逛細璋冪敤 - * <pre> - * System.setProperty("mail.mime.splitlongparameters", true) - * </pre> - * - * @param splitlongparameters 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠� - */ - public void setSplitlongparameters(boolean splitlongparameters) { - this.splitlongparameters = splitlongparameters; - } + /** + * 璁剧疆瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠斤紝榛樿涓篺alse锛堝浗鍐呴偖绠遍檮浠朵笉鏀寔鍒囧垎鐨勯檮浠跺悕锛�<br> + * 娉ㄦ剰姝ら」涓哄叏灞�璁剧疆锛屾椤逛細璋冪敤 + * <pre> + * System.setProperty("mail.mime.splitlongparameters", true) + * </pre> + * + * @param splitlongparameters 瀵逛簬瓒呴暱鍙傛暟鏄惁鍒囧垎涓哄浠� + */ + public void setSplitlongparameters(boolean splitlongparameters) { + this.splitlongparameters = splitlongparameters; + } - /** - * 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} - * - * @return 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} - * @since 5.7.16 - */ - public boolean isEncodefilename() { + /** + * 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} + * + * @return 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛岄粯璁や负 {@code true} + * @since 5.7.16 + */ + public boolean isEncodefilename() { - return encodefilename; - } + return encodefilename; + } - /** - * 璁剧疆瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛屾閫夐」涓嶄細淇敼鍏ㄥ眬閰嶇疆<br> - * 濡傛灉姝ら�夐」璁剧疆涓簕@code false}锛屽垯鏄惁缂栫爜鍙栧喅浜庝袱涓郴缁熷睘鎬э細 - * <ul> - * <li>mail.mime.encodefilename 鏄惁缂栫爜闄勪欢鏂囦欢鍚�</li> - * <li>mail.mime.charset 缂栫爜鏂囦欢鍚嶇殑缂栫爜</li> - * </ul> - * - * @param encodefilename 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜 - * @since 5.7.16 - */ - public void setEncodefilename(boolean encodefilename) { - this.encodefilename = encodefilename; - } + /** + * 璁剧疆瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜锛屾閫夐」涓嶄細淇敼鍏ㄥ眬閰嶇疆<br> + * 濡傛灉姝ら�夐」璁剧疆涓簕@code false}锛屽垯鏄惁缂栫爜鍙栧喅浜庝袱涓郴缁熷睘鎬э細 + * <ul> + * <li>mail.mime.encodefilename 鏄惁缂栫爜闄勪欢鏂囦欢鍚�</li> + * <li>mail.mime.charset 缂栫爜鏂囦欢鍚嶇殑缂栫爜</li> + * </ul> + * + * @param encodefilename 瀵逛簬鏂囦欢鍚嶆槸鍚︿娇鐢▄@link #charset}缂栫爜 + * @since 5.7.16 + */ + public void setEncodefilename(boolean encodefilename) { + this.encodefilename = encodefilename; + } - /** - * 鏄惁浣跨敤 STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� - * - * @return 鏄惁浣跨敤 STARTTLS瀹夊叏杩炴帴 - */ - public boolean isStarttlsEnable() { - return this.starttlsEnable; - } + /** + * 鏄惁浣跨敤 STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� + * + * @return 鏄惁浣跨敤 STARTTLS瀹夊叏杩炴帴 + */ + public boolean isStarttlsEnable() { + return this.starttlsEnable; + } - /** - * 璁剧疆鏄惁浣跨敤STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� - * - * @param startttlsEnable 鏄惁浣跨敤STARTTLS瀹夊叏杩炴帴 - * @return this - */ - public MailAccount setStarttlsEnable(boolean startttlsEnable) { - this.starttlsEnable = startttlsEnable; - return this; - } + /** + * 璁剧疆鏄惁浣跨敤STARTTLS瀹夊叏杩炴帴锛孲TARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� + * + * @param startttlsEnable 鏄惁浣跨敤STARTTLS瀹夊叏杩炴帴 + * @return this + */ + public MailAccount setStarttlsEnable(boolean startttlsEnable) { + this.starttlsEnable = startttlsEnable; + return this; + } - /** - * 鏄惁浣跨敤 SSL瀹夊叏杩炴帴 - * - * @return 鏄惁浣跨敤 SSL瀹夊叏杩炴帴 - */ - public Boolean isSslEnable() { - return this.sslEnable; - } + /** + * 鏄惁浣跨敤 SSL瀹夊叏杩炴帴 + * + * @return 鏄惁浣跨敤 SSL瀹夊叏杩炴帴 + */ + public Boolean isSslEnable() { + return this.sslEnable; + } - /** - * 璁剧疆鏄惁浣跨敤SSL瀹夊叏杩炴帴 - * - * @param sslEnable 鏄惁浣跨敤SSL瀹夊叏杩炴帴 - * @return this - */ - public MailAccount setSslEnable(Boolean sslEnable) { - this.sslEnable = sslEnable; - return this; - } + /** + * 璁剧疆鏄惁浣跨敤SSL瀹夊叏杩炴帴 + * + * @param sslEnable 鏄惁浣跨敤SSL瀹夊叏杩炴帴 + * @return this + */ + public MailAccount setSslEnable(Boolean sslEnable) { + this.sslEnable = sslEnable; + return this; + } - /** - * 鑾峰彇SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 - * - * @return SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 - * @since 5.5.7 - */ - public String getSslProtocols() { - return sslProtocols; - } + /** + * 鑾峰彇SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 + * + * @return SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 + * @since 5.5.7 + */ + public String getSslProtocols() { + return sslProtocols; + } - /** - * 璁剧疆SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 - * - * @param sslProtocols SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 - * @since 5.5.7 - */ - public void setSslProtocols(String sslProtocols) { - this.sslProtocols = sslProtocols; - } + /** + * 璁剧疆SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 + * + * @param sslProtocols SSL鍗忚锛屽涓崗璁敤绌烘牸鍒嗛殧 + * @since 5.5.7 + */ + public void setSslProtocols(String sslProtocols) { + this.sslProtocols = sslProtocols; + } - /** - * 鑾峰彇鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 - * - * @return 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�, 杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 - */ - public String getSocketFactoryClass() { - return socketFactoryClass; - } + /** + * 鑾峰彇鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 + * + * @return 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�, 杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 + */ + public String getSocketFactoryClass() { + return socketFactoryClass; + } - /** - * 璁剧疆鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 - * - * @param socketFactoryClass 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 - * @return this - */ - public MailAccount setSocketFactoryClass(String socketFactoryClass) { - this.socketFactoryClass = socketFactoryClass; - return this; - } + /** + * 璁剧疆鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 + * + * @param socketFactoryClass 鎸囧畾瀹炵幇javax.net.SocketFactory鎺ュ彛鐨勭被鐨勫悕绉�,杩欎釜绫诲皢琚敤浜庡垱寤篠MTP鐨勫鎺ュ瓧 + * @return this + */ + public MailAccount setSocketFactoryClass(String socketFactoryClass) { + this.socketFactoryClass = socketFactoryClass; + return this; + } - /** - * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true - * - * @return 濡傛灉璁剧疆涓簍rue, 鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true - */ - public boolean isSocketFactoryFallback() { - return socketFactoryFallback; - } + /** + * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true + * + * @return 濡傛灉璁剧疆涓簍rue, 鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true + */ + public boolean isSocketFactoryFallback() { + return socketFactoryFallback; + } - /** - * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true - * - * @param socketFactoryFallback 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true - * @return this - */ - public MailAccount setSocketFactoryFallback(boolean socketFactoryFallback) { - this.socketFactoryFallback = socketFactoryFallback; - return this; - } + /** + * 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true + * + * @param socketFactoryFallback 濡傛灉璁剧疆涓簍rue,鏈兘鍒涘缓涓�涓鎺ュ瓧浣跨敤鎸囧畾鐨勫鎺ュ瓧宸ュ巶绫诲皢瀵艰嚧浣跨敤java.net.Socket鍒涘缓鐨勫鎺ュ瓧绫�, 榛樿鍊间负true + * @return this + */ + public MailAccount setSocketFactoryFallback(boolean socketFactoryFallback) { + this.socketFactoryFallback = socketFactoryFallback; + return this; + } - /** - * 鑾峰彇鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� - * - * @return 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� - */ - public int getSocketFactoryPort() { - return socketFactoryPort; - } + /** + * 鑾峰彇鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� + * + * @return 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� + */ + public int getSocketFactoryPort() { + return socketFactoryPort; + } - /** - * 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� - * - * @param socketFactoryPort 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� - * @return this - */ - public MailAccount setSocketFactoryPort(int socketFactoryPort) { - this.socketFactoryPort = socketFactoryPort; - return this; - } + /** + * 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� + * + * @param socketFactoryPort 鎸囧畾鐨勭鍙h繛鎺ュ埌鍦ㄤ娇鐢ㄦ寚瀹氱殑濂楁帴瀛楀伐鍘傘�傚鏋滄病鏈夎缃�,灏嗕娇鐢ㄩ粯璁ょ鍙� + * @return this + */ + public MailAccount setSocketFactoryPort(int socketFactoryPort) { + this.socketFactoryPort = socketFactoryPort; + return this; + } - /** - * 璁剧疆SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 - * - * @param timeout SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 - * @return this - * @since 4.1.17 - */ - public MailAccount setTimeout(long timeout) { - this.timeout = timeout; - return this; - } + /** + * 璁剧疆SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 + * + * @param timeout SMTP瓒呮椂鏃堕暱锛屽崟浣嶆绉掞紝缂虹渷鍊间笉瓒呮椂 + * @return this + * @since 4.1.17 + */ + public MailAccount setTimeout(long timeout) { + this.timeout = timeout; + return this; + } - /** - * 璁剧疆Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - * - * @param connectionTimeout Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - * @return this - * @since 4.1.17 - */ - public MailAccount setConnectionTimeout(long connectionTimeout) { - this.connectionTimeout = connectionTimeout; - return this; - } + /** + * 璁剧疆Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + * + * @param connectionTimeout Socket杩炴帴瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + * @return this + * @since 4.1.17 + */ + public MailAccount setConnectionTimeout(long connectionTimeout) { + this.connectionTimeout = connectionTimeout; + return this; + } - /** - * 璁剧疆Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - * - * @param writeTimeout Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 - * @return this - * @since 5.8.3 - */ - public MailAccount setWriteTimeout(long writeTimeout) { - this.writeTimeout = writeTimeout; - return this; - } + /** + * 璁剧疆Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + * + * @param writeTimeout Socket鍐欏嚭瓒呮椂鍊硷紝鍗曚綅姣锛岀己鐪佸�间笉瓒呮椂 + * @return this + * @since 5.8.3 + */ + public MailAccount setWriteTimeout(long writeTimeout) { + this.writeTimeout = writeTimeout; + return this; + } - /** - * 鑾峰彇鑷畾涔夊睘鎬у垪琛� - * - * @return 鑷畾涔夊弬鏁板垪琛� - * @since 5.6.4 - */ - public Map<String, Object> getCustomProperty() { - return customProperty; - } + /** + * 鑾峰彇鑷畾涔夊睘鎬у垪琛� + * + * @return 鑷畾涔夊弬鏁板垪琛� + * @since 5.6.4 + */ + public Map<String, Object> getCustomProperty() { + return customProperty; + } - /** - * 璁剧疆鑷畾涔夊睘鎬э紝濡俶ail.smtp.ssl.socketFactory - * - * @param key 灞炴�у悕锛岀┖鐧借蹇界暐 - * @param value 灞炴�у�硷紝 null琚拷鐣� - * @return this - * @since 5.6.4 - */ - public MailAccount setCustomProperty(String key, Object value) { - if (StrUtil.isNotBlank(key) && ObjectUtil.isNotNull(value)) { - this.customProperty.put(key, value); - } - return this; - } + /** + * 璁剧疆鑷畾涔夊睘鎬э紝濡俶ail.smtp.ssl.socketFactory + * + * @param key 灞炴�у悕锛岀┖鐧借蹇界暐 + * @param value 灞炴�у�硷紝 null琚拷鐣� + * @return this + * @since 5.6.4 + */ + public MailAccount setCustomProperty(String key, Object value) { + if (StrUtil.isNotBlank(key) && ObjectUtil.isNotNull(value)) { + this.customProperty.put(key, value); + } + return this; + } - /** - * 鑾峰緱SMTP鐩稿叧淇℃伅 - * - * @return {@link Properties} - */ - public Properties getSmtpProps() { - //鍏ㄥ眬绯荤粺鍙傛暟 - System.setProperty(SPLIT_LONG_PARAMS, String.valueOf(this.splitlongparameters)); + /** + * 鑾峰緱SMTP鐩稿叧淇℃伅 + * + * @return {@link Properties} + */ + public Properties getSmtpProps() { + //鍏ㄥ眬绯荤粺鍙傛暟 + System.setProperty(SPLIT_LONG_PARAMS, String.valueOf(this.splitlongparameters)); - final Properties p = new Properties(); - p.put(MAIL_PROTOCOL, "smtp"); - p.put(SMTP_HOST, this.host); - p.put(SMTP_PORT, String.valueOf(this.port)); - p.put(SMTP_AUTH, String.valueOf(this.auth)); - if (this.timeout > 0) { - p.put(SMTP_TIMEOUT, String.valueOf(this.timeout)); - } - if (this.connectionTimeout > 0) { - p.put(SMTP_CONNECTION_TIMEOUT, String.valueOf(this.connectionTimeout)); - } - // issue#2355 - if (this.writeTimeout > 0) { - p.put(SMTP_WRITE_TIMEOUT, String.valueOf(this.writeTimeout)); - } + final Properties p = new Properties(); + p.put(MAIL_PROTOCOL, "smtp"); + p.put(SMTP_HOST, this.host); + p.put(SMTP_PORT, String.valueOf(this.port)); + p.put(SMTP_AUTH, String.valueOf(this.auth)); + if (this.timeout > 0) { + p.put(SMTP_TIMEOUT, String.valueOf(this.timeout)); + } + if (this.connectionTimeout > 0) { + p.put(SMTP_CONNECTION_TIMEOUT, String.valueOf(this.connectionTimeout)); + } + // issue#2355 + if (this.writeTimeout > 0) { + p.put(SMTP_WRITE_TIMEOUT, String.valueOf(this.writeTimeout)); + } - p.put(MAIL_DEBUG, String.valueOf(this.debug)); + p.put(MAIL_DEBUG, String.valueOf(this.debug)); - if (this.starttlsEnable) { - //STARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� - p.put(STARTTLS_ENABLE, "true"); + if (this.starttlsEnable) { + //STARTTLS鏄绾枃鏈�氫俊鍗忚鐨勬墿灞曘�傚畠灏嗙函鏂囨湰杩炴帴鍗囩骇涓哄姞瀵嗚繛鎺ワ紙TLS鎴朣SL锛夛紝 鑰屼笉鏄娇鐢ㄤ竴涓崟鐙殑鍔犲瘑閫氫俊绔彛銆� + p.put(STARTTLS_ENABLE, "true"); - if (null == this.sslEnable) { - //涓轰簡鍏煎鏃х増鏈紝褰撶敤鎴锋病鏈夋椤归厤缃椂锛屾寜鐓tarttlsEnable寮�鍚姸鎬佹椂瀵瑰緟 - this.sslEnable = true; - } - } + if (null == this.sslEnable) { + //涓轰簡鍏煎鏃х増鏈紝褰撶敤鎴锋病鏈夋椤归厤缃椂锛屾寜鐓tarttlsEnable寮�鍚姸鎬佹椂瀵瑰緟 + this.sslEnable = true; + } + } - // SSL - if (null != this.sslEnable && this.sslEnable) { - p.put(SSL_ENABLE, "true"); - p.put(SOCKET_FACTORY, socketFactoryClass); - p.put(SOCKET_FACTORY_FALLBACK, String.valueOf(this.socketFactoryFallback)); - p.put(SOCKET_FACTORY_PORT, String.valueOf(this.socketFactoryPort)); - // issue#IZN95@Gitee锛屽湪Linux涓嬮渶鑷畾涔塖SL鍗忚鐗堟湰 - if (StrUtil.isNotBlank(this.sslProtocols)) { - p.put(SSL_PROTOCOLS, this.sslProtocols); - } - } + // SSL + if (null != this.sslEnable && this.sslEnable) { + p.put(SSL_ENABLE, "true"); + p.put(SOCKET_FACTORY, socketFactoryClass); + p.put(SOCKET_FACTORY_FALLBACK, String.valueOf(this.socketFactoryFallback)); + p.put(SOCKET_FACTORY_PORT, String.valueOf(this.socketFactoryPort)); + // issue#IZN95@Gitee锛屽湪Linux涓嬮渶鑷畾涔塖SL鍗忚鐗堟湰 + if (StrUtil.isNotBlank(this.sslProtocols)) { + p.put(SSL_PROTOCOLS, this.sslProtocols); + } + } - // 琛ュ厖鑷畾涔夊睘鎬э紝鍏佽鑷畾灞炴�ц鐩栧凡缁忚缃殑鍊� - p.putAll(this.customProperty); + // 琛ュ厖鑷畾涔夊睘鎬э紝鍏佽鑷畾灞炴�ц鐩栧凡缁忚缃殑鍊� + p.putAll(this.customProperty); - return p; - } + return p; + } - /** - * 濡傛灉鏌愪簺鍊间负null锛屼娇鐢ㄩ粯璁ゅ�� - * - * @return this - */ - public MailAccount defaultIfEmpty() { - // 鍘绘帀鍙戜欢浜虹殑濮撳悕閮ㄥ垎 - final String fromAddress = InternalMailUtil.parseFirstAddress(this.from, this.charset).getAddress(); + /** + * 濡傛灉鏌愪簺鍊间负null锛屼娇鐢ㄩ粯璁ゅ�� + * + * @return this + */ + public MailAccount defaultIfEmpty() { + // 鍘绘帀鍙戜欢浜虹殑濮撳悕閮ㄥ垎 + final String fromAddress = InternalMailUtil.parseFirstAddress(this.from, this.charset).getAddress(); - if (StrUtil.isBlank(this.host)) { - // 濡傛灉SMTP鍦板潃涓虹┖锛岄粯璁や娇鐢╯mtp.<鍙戜欢浜洪偖绠卞悗缂�> - this.host = StrUtil.format("smtp.{}", StrUtil.subSuf(fromAddress, fromAddress.indexOf('@') + 1)); - } - if (StrUtil.isBlank(user)) { - // 濡傛灉鐢ㄦ埛鍚嶄负绌猴紝榛樿涓哄彂浠朵汉锛坕ssue#I4FYVY@Gitee锛� - //this.user = StrUtil.subPre(fromAddress, fromAddress.indexOf('@')); - this.user = fromAddress; - } - if (null == this.auth) { - // 濡傛灉瀵嗙爜闈炵┖鐧斤紝鍒欎娇鐢ㄨ璇佹ā寮� - this.auth = (false == StrUtil.isBlank(this.pass)); - } - if (null == this.port) { - // 绔彛鍦⊿SL鐘舵�佷笅榛樿涓巗ocketFactoryPort涓�鑷达紝闈濻SL鐘舵�佷笅榛樿涓�25 - this.port = (null != this.sslEnable && this.sslEnable) ? this.socketFactoryPort : 25; - } - if (null == this.charset) { - // 榛樿UTF-8缂栫爜 - this.charset = CharsetUtil.CHARSET_UTF_8; - } + if (StrUtil.isBlank(this.host)) { + // 濡傛灉SMTP鍦板潃涓虹┖锛岄粯璁や娇鐢╯mtp.<鍙戜欢浜洪偖绠卞悗缂�> + this.host = StrUtil.format("smtp.{}", StrUtil.subSuf(fromAddress, fromAddress.indexOf('@') + 1)); + } + if (StrUtil.isBlank(user)) { + // 濡傛灉鐢ㄦ埛鍚嶄负绌猴紝榛樿涓哄彂浠朵汉锛坕ssue#I4FYVY@Gitee锛� + //this.user = StrUtil.subPre(fromAddress, fromAddress.indexOf('@')); + this.user = fromAddress; + } + if (null == this.auth) { + // 濡傛灉瀵嗙爜闈炵┖鐧斤紝鍒欎娇鐢ㄨ璇佹ā寮� + this.auth = (false == StrUtil.isBlank(this.pass)); + } + if (null == this.port) { + // 绔彛鍦⊿SL鐘舵�佷笅榛樿涓巗ocketFactoryPort涓�鑷达紝闈濻SL鐘舵�佷笅榛樿涓�25 + this.port = (null != this.sslEnable && this.sslEnable) ? this.socketFactoryPort : 25; + } + if (null == this.charset) { + // 榛樿UTF-8缂栫爜 + this.charset = CharsetUtil.CHARSET_UTF_8; + } - return this; - } + return this; + } - @Override - public String toString() { - return "MailAccount [host=" + host + ", port=" + port + ", auth=" + auth + ", user=" + user + ", pass=" + (StrUtil.isEmpty(this.pass) ? "" : "******") + ", from=" + from + ", startttlsEnable=" - + starttlsEnable + ", socketFactoryClass=" + socketFactoryClass + ", socketFactoryFallback=" + socketFactoryFallback + ", socketFactoryPort=" + socketFactoryPort + "]"; - } + @Override + public String toString() { + return "MailAccount [host=" + host + ", port=" + port + ", auth=" + auth + ", user=" + user + ", pass=" + (StrUtil.isEmpty(this.pass) ? "" : "******") + ", from=" + from + ", startttlsEnable=" + + starttlsEnable + ", socketFactoryClass=" + socketFactoryClass + ", socketFactoryFallback=" + socketFactoryFallback + ", socketFactoryPort=" + socketFactoryPort + "]"; + } } -- Gitblit v1.9.3