Confusing warning during compilation: Warning: MATLAB preference entry "SMTP_Username" has been removed.

8 ビュー (過去 30 日間)
I use sendmail in a compiled program that sends email via a generic gmail address. Username and password are set via:
setpref('Internet','SMTP_Username',sender)
setpref('Internet','SMTP_Password',passwd)
When compiling with Compiler version: 8.1 (R2020b), I get the following warnings:
Warning: MATLAB preference entry "SMTP_Username" has been removed.
Warning: MATLAB preference entry "SMTP_Password" has been removed.
Still the code perfoms OK.
I don't really understand what this means, whether this is a feature that will be removed in future releases...
I could not find any information at mathworks or the internet in general. Any pointer is appreciated!
  5 件のコメント
Clayton Gotberg
Clayton Gotberg 2021 年 4 月 26 日
I wonder if that is either to warn about or to repair this security issue? It seems that you're correct about MATLAB not wanting those preferences to be hard-coded!
Eric Delgado
Eric Delgado 2021 年 7 月 16 日
Hi @Ralf, it seems like a "default warning". I am still learning "Matlab Compiler" and made I simple app with no SMTP settings... but I receive this warning anyway.
Let me ask you something... :)
Do you know what is the best approach to deal with a big app that calls Python, for example? Should I build an app just to configure pyenv and my app PATHS, for example?

サインインしてコメントする。

採用された回答

Mohammad Sami
Mohammad Sami 2021 年 7 月 19 日
編集済み: Mohammad Sami 2021 年 7 月 19 日
This is the correct behaviour for security reasons. Otherwise this information will be included from the previously set values in your Matlab environment if any. This would have happened regardless of whether you were using the mail function in your compiled program. These values would then have been exposed (visible in plain text) once you distribute your program to others.
Therefore you will need to use the setpref function in your code to set these values before you try to send the emails. You can also prompt the user for these values, then call the setpref function using the entered values.
  4 件のコメント
Augustin Thepaut
Augustin Thepaut 2023 年 6 月 8 日
Hey! Thanks for the response is such short notice! Ok I understand. However, I am wondering for instance how compagnies send email automatically to their users (for a report for instance), if you cant set this properly?
Not sure I am really clear here but it is just curiousity anyway (more like culture).
Thanks again!
Walter Roberson
Walter Roberson 2023 年 6 月 9 日
Normally, at the time you compile an executable using MATLAB Compiler, MATLAB Compiler reads the current user's environment variables and turns them into internal setpref() in the executable. However, if the user who is doing the compiling has either of the environment variables SMTP_Username or SMTP_Password set, then MATLAB Compiler issues a warning message and does not insert those values into the executable.
Then at run time, if the code has not been set up to create those environment variables but a user identity is needed, then at runtime the code would look at the SMTP_Username or SMTP_Password environment variables of the user who is running the code.
It is uncommon that you would want the mail username and password of the person doing the compiling to be coded into the executable. In the cases where the person building the code does want that, then there are a number of ways that the code could be written to hard-code the username and password; the exact means used would depend upon the security policies of the organization.

サインインしてコメントする。

その他の回答 (1 件)

Derek Wolfe
Derek Wolfe 2021 年 10 月 1 日
I ran into the same issue. My compile script uses the following to clear Internet preferences before building:
% clear email preferences
if (isempty(getpref('Internet')) == false)
rmpref('Internet');
end

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by