sendmail works when I run my app but not when another user uses it in a packaged app

조회 수: 2 (최근 30일)
Hello,
I made an app in app designer and part of the app asks the user to input their e-mail address and then the app sends them a "report" of sorts at the end of using the app when they push a "submit" button. The code I write is below.
The issue here is that when I push the submit button, it works and sends me the e-mail. When I sent it out to a friend to test drive, it gave them a "ding" and didn't send the e-mail. Is there anything not packaged up with the app when you create a standalone desktop app that might prevent that functionality?
data={1:10}
out_email=input('email','type the recipient email');
filename=['testing.xlsx'];
filepath=[cd '\' filename];
writecell(data,filepath);
user = getenv('username');
mail = 'myemail@gmail.com'; %my ghost GMail email address
password = 'mypassword'; % ghost GMail password
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
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');
sendmail(out_email{:},'Results',{'testing'},filepath)
delete(filepath) %I don't want the user to necesarrily have a copy of the file stored for them - only sent to the provided email
Looking forward to suggestions/thoughts.
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2020년 9월 12일
They probably need to enable gmail "Less Secure Apps" in order for MATLAB to send to gmail .
  댓글 수: 16
Adam Danz
Adam Danz 2020년 9월 14일
Nearly all of the sendemail errors I've seen are either from incorrect syntax/inputs or with software on local machines that are blocking it (which is usually a good thing). Thanks for letting us know what the probem was, Shae.
Shae Morgan
Shae Morgan 2020년 10월 16일
@Adam Danz @Walter Roberson
Sending the e-mail works now on windows machines, but not on MAC. I've compiled the app for mac, but when users install the program, it gets hung up on the line of code where you set preferences:
setpref('Internet','SMTP_Server','smtp.gmail.com');
Any idea if the name of preference information is different on a OS X compared to PC?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by