0
votes

I am using javamail for a mail client application. I have added an iCloud account with SMTP TLS for outgoing, and imap for incoming

acct.iIncomingHostType = Constants.HOSTTYPE_IMAP;
acct.sIncomingHost = "imap.mail.me.com";
acct.sIncomingHostPort = "993";
acct.iIncomingHostEncryption = Constants.ENCRYPT_SSL;

acct.sOutgoingHost = "smtp.mail.me.com";
acct.sOutgoingHostPort = "587";
acct.iOutgoingHostEncryption = Constants.ENCRYPT_TLS;
acct.bOutgoingHostSPALogin = false;

Now when I send a mail, it's reaching the recipient mailbox - be it gmail or outlook etc, but the mail sent is not coming in the sent folder of my iCloud account.

Code looks as below

Properties props = new Properties();
            /// sProtocol is "smtp"
            props.setProperty("mail.debug", "true");

            props.setProperty("mail.transport.protocol", sProtocol);
            props.setProperty("mail.host", acct.sOutgoingHost);
            props.setProperty("mail." + sProtocol + ".port",
                    acct.sOutgoingHostPort);
            props.setProperty("mail." + sProtocol + ".socketFactory.port",
                    acct.sOutgoingHostPort);
            props.setProperty("mail." + sProtocol + ".timeout", "30000");
            props.setProperty("mail." + sProtocol + ".connectiontimeout",
                    "30000");


            props.setProperty("mail." + sProtocol + ".auth", "true");

            props.setProperty("mail.debug.auth", "true");


            props.setProperty("mail." + sProtocol + ".sasl.enable", "true");



                props.setProperty("mail." + sProtocol + ".starttls.enable",
                        "true");
                props.setProperty("mail." + sProtocol + ".ssl.trust", "*");

                props.setProperty("mail." + sProtocol
                        + ".ssl.socketFactory.class",
                        "com.isaacdanielgroup.sempostmark.SEMPSSLSocketFactory");
                props.setProperty("mail." + sProtocol
                        + ".ssl.socketFactory.fallback", "false");
1

1 Answers

1
votes

First, you might be able to simplify your program by getting rid of all the socket factory stuff.

There's no magic that causes sent messages to be added to the Sent folder. If you want a copy of the message there, you need to put it there yourself. See the msgsend.java sample program for an example.