How to send SMS using gmail account?

1 view (last 30 days)
venkatesh kanagaluru
venkatesh kanagaluru on 21 Oct 2019
Edited: Rik on 21 Oct 2019
i tried with the following code by repaling my gmail account and passord and also with receiver gmail account.
setpref('Internet','E_mail','MygmailAccount');
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username','MygmailAccount');
setpref('Internet','SMTP_Password','MyGmailPassword');
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.starttls.enable','true');
props.setProperty('mail.smtp.socketFactory.class','javax.net.ss1.SSLSocketFactory');
props.setProperty( 'mail.smtp.socketFactory.port', '587' );
emailto = 'ReceiverGmailAccount'; % recipient's email
sendmail(emailto, 'matlab', 'welcome to the matlab world');
But getting the following error
Error using sendmail (line 171)
Could not connect to SMTP host: smtp.gmail.com, port: 25;
Connection timed out: connect
Error in emailsending (line 14)
sendmail(emailto, 'matlab', 'welcome to the matlab world');
Can someone help on this..thanking you in advance

Answers (0)

Community Treasure Hunt

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

Start Hunting!