Errors updating MATLAB Web App Server from r2020b to r2023b

13 views (last 30 days)
Dear MATLAB users,
i got some problems, when I'm trying to update the MATLAB Web App Server and some Web Apps from r2020b to r2023b.
1) sendmail function: Is this function not available on MATLAB Web App Server anymore, only local?
code:
subject = ['Subject xyz];
setpref('Internet','SMTP_Server','smtprelay.dmycompany.local');
setpref('Internet','E_mail','xyz@mycompany.com');
mail.Body = sprintf('This is a test.');
sendmail(user@gmail.com, subject, mail.Body, test1.pdf);
error:
2023-11-20 18:01:46 Error using matlab.internal.lang.capability.Capability.require
2023-11-20 18:01:46 This functionality is not available on remote platforms.
2023-11-20 18:01:46 Error in sendmail (line 38)
2) WebSockets protocol? I didn't get this error in the older version.
WebSockets protocol was not established. This may cause performance degradation and occasional errors. Contact your System Administrator
Could you please help me?
Kind regards

Accepted Answer

Sanchari
Sanchari on 29 Nov 2023
Hello C.K.,
I understand that you are trying to fix the errors related to MATLAB Web App Server.
The error messages you provided indicate that the “sendmail” function is not available on remote platforms. When working in a remote environment, you may encounter restrictions on certain functions or capabilities due to security or system limitations. In this case, the “sendmail” function is being restricted by the capabilities of the remote platform.
To address this issue, consider the following steps:
  1. Enable less-secure app access feature for Google: To send an email through your Gmail account you must turn off the app security which greatly reduces the security of your Gmail account. One solution to this problem is creating a new Gmail account for the sole purpose of sending emails from this script. This link provides information on how to enable the less-secure app access, https://support.google.com/accounts/answer/6010255. To turn off app security, sign into gmail and access this link: https://myaccount.google.com/lesssecureapps.
  2. Disable AntiVirus: Turn off AntiVirus after implementing the above step. Also, disable the two step verification, if it shows. This should help to fix the error with WebSocket protocol.
  3. Example code: You can follow the example code below.
% User input
source = 'myFakeEmail@gmail.com'; %from address (gmail)
destination = 'kofte@foobar.com'; %to address (any mail service)
myEmailPassword = 'sifre123'; %the password to the 'from' account
subj = 'This is the subject line of the email'; % subject line
msg = 'This is the main body of the email.'; % main body of email.
%set up SMTP service for Gmail
setpref('Internet','E_mail',source);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',source);
setpref('Internet','SMTP_Password',myEmailPassword);
% Gmail server.
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
% Send the email
sendmail(destination,subj,msg);
% [Optional] Remove the preferences (for privacy reasons)
setpref('Internet','E_mail','');
setpref('Internet','SMTP_Server','''');
setpref('Internet','SMTP_Username','');
setpref('Internet','SMTP_Password','');
The “sendmail” function should be able to work after that.
Please refer the documentation for “sendmail” function to use with email servers that require authentication, like gmail, here: https://www.mathworks.com/help/matlab/ref/sendmail.html
Please refer the following ML Answers Learning for further clarification with issues regarding sendmail function:
  1. Sending E-mail error: https://www.mathworks.com/matlabcentral/answers/433031-sending-e-mail-error?s_tid=srchtitle#answer_349841
  2. Sending mail from gmail using sendmail() after authenticating less secure apps access on Google: https://www.mathworks.com/matlabcentral/answers/464564-sending-mail-from-gmail-using-sendmail?s_tid=srchtitle
  3. Send Email using gmail failed: https://www.mathworks.com/matlabcentral/answers/541514-send-email-using-gmail-failed
  4. Valid base error problem in sending email for matlab: https://www.mathworks.com/matlabcentral/answers/484098-base-error-problem-in-sending-email-for-matlab?s_tid=srchtitle
  5. Using gmail after May 30, 2022: https://www.mathworks.com/matlabcentral/answers/1672544-using-gmail-after-may-30-2022?s_tid=srchtitle
Hope this information is helpful to you!
  2 Comments
C. K.
C. K. on 29 Nov 2023
Edited: C. K. on 29 Nov 2023
Hi Sanchari,
thank you for this very detailed explanation. This really helps me a lot.
kind regards
Christian
Thomas Watson
Thomas Watson on 30 Nov 2023
Hi @Sanchari, is there a more technical explanation or list of troubleshooting steps concerning the WebSocket protocol issue that doesn't involve disabling AntiVirus software? Thank you

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!