for en engineering class i need to create a function that will send an email when under specific conditions, this is what ive written so far but it keep getting the error 'to many outputs'
1 view (last 30 days)
Show older comments
Nathan Fischbach
on 6 Oct 2019
Commented: Walter Roberson
on 6 Oct 2019
function [m,s] = Door_Status(x)
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','E_mail','myuser@gmail.com');
setpref('Internet','SMTP_Username','myuser');
setpref('Internet','SMTP_Password','mypassword');
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');
if x==true
m = sendmail('recipiant@gmail.com','Door Status Update Code','true') ;
elseif x==false
s = sendmail('recipiant@gmail.com','Door Status Update Code','true') ;
end
end
0 Comments
Accepted Answer
Walter Roberson
on 6 Oct 2019
sendmail() does not return a value.
Question: why are you sending the same message for x true as for x false?
2 Comments
Walter Roberson
on 6 Oct 2019
sendmail() causes the message to be sent. It does not "prepare" a message to be sent with some later "yes, send it now" trigger: it does the sending.
More Answers (1)
Steven Lord
on 6 Oct 2019
The documentation for the sendmail function does not list any syntax that has an output argument. Eliminate the output arguments from your calls to sendmail. You're probably also going to want to eliminate the output arguments from your function declaration line.
You also might want to check the text of the messages you're sending. I think you expect it to be different based on what the input is, but it's not.
0 Comments
See Also
Categories
Find more on Web Services in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!