Questions Tagged With emailhttps://answers.axonivy.com/tags/email/?type=rss&user=nguyen_toquestions tagged <span class="tag">email</span>enThu, 10 May 2018 00:29:22 -0400Cannot send email in designer using SimpleMailSender APIhttps://answers.axonivy.com/questions/3262/cannot-send-email-in-designer-using-simplemailsender-api<p>Hi, I'm trying to use ivy API to send mail in my Designer (v7.1.0.58009). I send an email with code snippet like this:</p> <p><code> SimpleMailSender mailSender = new SimpleMailSender(attachmentFiles, emailConfig, Ivy.log()); mailSender.sendMessage(); </code></p> <p>But I got an exception with content: </p><pre>Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; nested exception is: java.net.ConnectException: Connection refused: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2118) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:712) at javax.mail.Service.connect(Service.java:366) at javax.mail.Service.connect(Service.java:246) at javax.mail.Service.connect(Service.java:195) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) at ch.ivyteam.ivy.email.internal.SendMail.doSendMessage(SendMail.java:136) at ch.ivyteam.util.callable.AbstractExecutionContext.lambda$0(AbstractExecutionContext.java:28) at ch.ivyteam.util.callable.AbstractExecutionContext.callInContext(AbstractExecutionContext.java:16) at ch.ivyteam.util.callable.AbstractExecutionContext.executeInContext(AbstractExecutionContext.java:26) at ch.ivyteam.ivy.email.internal.SendMail.sendMessage(SendMail.java:115) at ch.ivyteam.ivy.email.SimpleMailSender.sendMessage(SimpleMailSender.java:94) at ch.ivy.gawfs.mail.Mail.lambda$0(Mail.java:29) at ch.ivyteam.util.callable.AbstractExecutionContext.callInContext(AbstractExecutionContext.java:16) at ch.ivyteam.ivy.security.internal.SecurityManager.executeAsSystem(SecurityManager.java:1128) at ch.ivy.addon.portalkit.util.IvyExecutor.executeAsSystem(IvyExecutor.java:14) ... 123 more </pre><p></p> <p>I think the problem is that API SimpleMailSender.sendMessage() uses <strong>port 25</strong> which is cannot be accessed to connect to SMTP server: <strong>Couldn't connect to host, port: localhost, 25; timeout -1</strong>. I also tested email sending function with UI and could send email successfully: <img alt="alt text" src="https://answers.axonivy.com/upfiles/Capture_6KER93W.PNG"></p> <p>You see, it's using port <strong>2525</strong>. If I change port to <strong>25</strong>, I cannot send email. So how can I config the port when sending the email with ivy API? Thank you</p>nguyen_toThu, 10 May 2018 00:29:22 -0400https://answers.axonivy.com/questions/3262/cannot-send-email-in-designer-using-simplemailsender-apidesigneremail