Trouble with sending emails - Can't send command to SMTP host

13 次查看(过去 30 天)
SOLVED
Hello all,
I am currently using sendmail function on MATLAB R2022a to periodically send emails to designated email adresses. I created a graphical user interface and performed numerous trials which were successful and working smoothly. However, after compiling it to be a standalone application and deployed it to another computer connected to another network, it started throwing the following error:
Identifier:
MATLAB:sendmail:SmtpError
Message:
Can't send command to SMTP host;sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
The very same SMTP configuration (server, adress, password, port) works without any trouble on my computer. But it throws the error above on another computer. This makes me think that the code is properly working and the problem is with other computers network. My initial guess was that Windows firewall was blocking the email transfer, so I added a new rule to inbound and outbound rules for the standalone application, which didn't work.
However, maybe I should have added the rule as port. I will be trying this as soon as possible.
The computer has an antivirus software which might also be blocking the transfer. I will temporarily disable the antivirus and then try. If it works, I will be adding an exception to the antivirus so that it allows the application.
Do you have any idea on what the problem and other possible solutions might be?
I thank you for your answers in advance.
Solution for my case:
The issue was related to the server certification, so I added the following line of code to make sure that it trusts the server regardless of its certification:
props.setProperty('mail.smtp.ssl.trust', '*')
  2 个评论
Yash Srivastava
Yash Srivastava 2022-9-8
In order to assist you, I need some more information.
  1. Can you provide the complete error message?
  2. Is the network connected through a proxy?
Ergin Sezgin
Ergin Sezgin 2022-9-8
Hello Yash,
  1. Complete message in the MException data seems to be as the following: Can't send command to SMTP host;sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  2. I just checked but it seems it is not connected through proxy.
I researched a bit more and noticed that some people has came across with very similar error during the MATLAB installation and java installation resolved the issue. I tried the application on a computer on which Java is never installed and the app worked, so my issue is probably not related to Java.
In a similar question, Dear Adam Danz mentioned that disabling the antivirus and firewall might resolve the issue. I will try it today.
Thank you for your time.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by