@@ -702,7 +702,7 @@ public class SendAction extends ProgressableAction {
702702
703703 private static final Logger log = Logger .getLogger (SendAction .class .getName ());
704704 private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory" ;
705-
705+
706706 private List <String > attachments = null ;
707707 private MailboxSetup ms = null ;
708708 private boolean readReceipt = false ;
@@ -751,6 +751,9 @@ public boolean execute() throws Exception {
751751
752752 this .progress ("Verbinde..." );
753753 Properties props = new Properties ();
754+ props .setProperty ("mail.imap.partialfetch" , "false" );
755+ props .setProperty ("mail.imaps.partialfetch" , "false" );
756+ props .setProperty ("mail.store.protocol" , ms .getEmailInType ());
754757
755758 if (ms .isEmailOutSsl ()) {
756759 props .put ("mail.smtp.ssl.enable" , "true" );
@@ -794,11 +797,23 @@ public boolean execute() throws Exception {
794797 props .setProperty ("mail.imaps.socketFactory.port" , "993" );
795798 props .setProperty ("mail.imaps.starttls.enable" , "true" );
796799 } else {
800+
801+ props .setProperty ("mail.imaps.host" , ms .getEmailInServer ());
802+ props .setProperty ("mail.imap.host" , ms .getEmailInServer ());
803+
804+ if (ms .isEmailInSsl ())
805+ props .setProperty ("mail.store.protocol" , "imaps" );
806+
797807 props .setProperty ("mail.store.protocol" , ms .getEmailInType ());
798808 if (ms .isEmailInSsl ()) {
799809 props .setProperty ("mail." + ms .getEmailInType () + ".ssl.enable" , "true" );
800810 }
801-
811+ ServerSettings sset = ServerSettings .getInstance ();
812+ String trustedServers = sset .getSetting ("mail.imaps.ssl.trust" , "" );
813+ if (trustedServers .length () > 0 ) {
814+ props .put ("mail.imaps.ssl.trust" , trustedServers );
815+ }
816+
802817 }
803818
804819 javax .mail .Authenticator auth = new javax .mail .Authenticator () {
@@ -952,25 +967,31 @@ public PasswordAuthentication getPasswordAuthentication() {
952967 Store store = null ;
953968 if (ms .isMsExchange ()) {
954969 String authToken = MsExchangeUtils .getAuthToken (ms .getTenantId (), ms .getClientId (), ms .getClientSecret (), ms .getEmailInUser (), Crypto .decrypt (ms .getEmailInPwd ()));
955-
970+
956971 session = Session .getInstance (props );
957972 store = session .getStore ("imaps" );
958973 store .connect (ms .getEmailInServer (), ms .getEmailInUser (), authToken );
959974
960975 } else {
961-
976+
962977 props .setProperty ("mail.imaps.host" , ms .getEmailInServer ());
963978 props .setProperty ("mail.imap.host" , ms .getEmailInServer ());
964-
965- if (ms .isEmailInSsl ())
979+
980+ if (ms .isEmailInSsl ()) {
966981 props .setProperty ("mail.store.protocol" , "imaps" );
967-
982+ }
983+
984+ props .setProperty ("mail.store.protocol" , ms .getEmailInType ());
985+ if (ms .isEmailInSsl ()) {
986+ props .setProperty ("mail." + ms .getEmailInType () + ".ssl.enable" , "true" );
987+ }
968988 ServerSettings sset = ServerSettings .getInstance ();
969989 String trustedServers = sset .getSetting ("mail.imaps.ssl.trust" , "" );
970- if (trustedServers .length () > 0 )
971- props .put ("mail.imaps.ssl.trust" , "mail.your-server.de" );
990+ if (trustedServers .length () > 0 ) {
991+ props .put ("mail.imaps.ssl.trust" , trustedServers );
992+ }
972993
973- store = session .getStore ();
994+ store = session .getStore ();
974995 //store.connect(ms.getEmailInServer(), ms.getEmailInUser(), Crypto.decrypt(ms.getEmailInPwd()));
975996 store .connect ();
976997 }
@@ -983,13 +1004,15 @@ public PasswordAuthentication getPasswordAuthentication() {
9831004 Folder sent = EmailUtils .getSentFolder (store );
9841005 if (sent != null ) {
9851006 this .progress ("Kopiere Nachricht in 'Gesendet'..." );
986- boolean closed = !sent .isOpen ();
987- if (!sent .isOpen ())
1007+ boolean closed = !sent .isOpen ();
1008+ if (!sent .isOpen ()) {
9881009 sent .open (Folder .READ_WRITE );
1010+ }
9891011 msg .setFlag (Flags .Flag .SEEN , true );
9901012 sent .appendMessages (new Message []{msg });
991- if (closed )
1013+ if (closed ) {
9921014 EmailUtils .closeIfIMAP (sent );
1015+ }
9931016
9941017 } else {
9951018 log .error ("Unable to determine 'Sent' folder for mailbox" );
0 commit comments