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

조회 수: 13 (최근 30일)
Ergin Sezgin
Ergin Sezgin 2022년 9월 5일
편집: Ergin Sezgin 2022년 9월 9일
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