I writing a email client using simple java mail API and it queue for sending but I did not receive any email.
Execution Info:
INFO: SESSION[1] bridging to remote proxy http://10.64.150.9:8080, username: [email protected], proxy bridge @ localhost:1081
My Code:
public void sendEmail() {
try {
init();
DataSource fileData = new FileDataSource(new File(".\\report\\Test-Report.html"));
Email aEmail = EmailBuilder.startingBlank()
.from("Peter Wong", "[email protected]")
.to(recipientList)
.withSubject("ePQS Automation Testing Report")
.withPlainText("Please find the ePQS Automation Testing Report from attachment")
.withAttachment("ePQS Automation Test Report", fileData)
.withBounceTo("[email protected]")
.buildEmail();
Mailer mailer = MailerBuilder
.withSMTPServer("smtp.gmail.com", 587, "[email protected]", "1234")
.withTransportStrategy(TransportStrategy.SMTP_TLS)
.withProxy("http://10.64.150.9", 8080, "[email protected]", crypt.decryptPwd(".\\password\\peter_wong_wims.txt"))
.withSessionTimeout(10 * 1000)
.clearEmailAddressCriteria() // turns off email validation
.withDebugLogging(true)
.buildMailer();
mailer.sendMail(aEmail, true);
} catch (Exception ex) {
LogManager.logger.log(Level.INFO, "Exception: " + ex.getMessage());
}
}
I"m behind corporate proxy and connect to internet require this corporate proxy. What is the problem? Please help. A billion thanks in advance.
PS: Occasionally i encounter this error
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 10000; Using SOCKS host, port: localhost, 1081;
Latest:
DEBUG: setDebug: JavaMail version 1.6.0 Dec 31, 2018 3:40:03 PM org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server run INFO: Starting proxy server at port 1081 Dec 31, 2018 3:40:03 PM org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server run INFO: waiting for new connection... DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle] DEBUG SMTP: need username and password for authentication DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user=kwong, password= DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false Dec 31, 2018 3:40:03 PM org.simplejavamail.mailer.internal.socks.socks5server.SocksSession INFO: SESSION[1] opened from /127.0.0.1:36846 Dec 31, 2018 3:40:03 PM org.simplejavamail.mailer.internal.socks.socks5server.AnonymousSocks5Server run INFO: waiting for new connection... Dec 31, 2018 3:40:03 PM org.simplejavamail.mailer.internal.socks.AuthenticatingSocks5Bridge createSocketAuthenticated INFO: SESSION[1] bridging to remote proxy https://10.64.150.9:8080, username: [email protected], proxy bridge @ localhost:1081