|function recipient = matlabmail(recipient, message, subject, sender, psswd)|
|% MATLABMAIL Send an email from a predefined gmail account.|
|% MATLABMAIL( recipient, message, subject )|
|% sends the character string stored in 'message' with subjectline 'subject'|
|% to the address in 'recipient'.|
|% This requires that the sending address is a GMAIL email account.|
|% MATLABMAIL( recipient, message, subject, sender, passwd )|
|% avoids using the stored credentials.|
|% Note: Authentication failed when my gmail account had 2-step verification enabled.|
|% There's no example because we don't know your email address!|
|% Try to adapt the following:|
|% pause(60*(1+randi(5))); matlabmail('firstname.lastname@example.org', 'done pausing', 'command complete');|
|% See also SENDMAIL|
|sender = 'email@example.com';|
|psswd = 'password_of_dummy_address';|
|props = java.lang.System.getProperties;|
|sendmail(recipient, subject, message);|
@ameer: You have to enable less secure apps by visiting https://www.google.com/settings/security/lesssecureapps
With Ubuntu running MATLAB Version: 220.127.116.111360 (R2016a)
However, this works on my MacOS with R2012a proving it can work in principle (and I do have my google settings allowing less secure apps). Does one need to create some kind of encryption key?
I had a similar problem and it was because I was using OpenJDK (Ubuntu 16.04, Matlab 2017a).
I had to use OpenJDK to avoid a display bug in Matlab's default JVM. But once I fixed that bug and went back to
Would be nice to know how to fix sendmail for OpenJDK though
good working code.In sender, Gmail account setting will be changed.