Sending an email via Matlab, how do I fix an 'Authentication failed' error?

23 visualizzazioni (ultimi 30 giorni)
I'm having trouble with sending emails through Matlab. I read about it, and tried all kinds of suggestions. Here is a detailed example for the type of codes I've been trying:
% parameters
mail = ''; % my gmail address
password = 'mypassword'; % my gmail password
host = '';
% preferences
setpref('Internet','SMTP_Server', host);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.socketFactory.class', '');
% Send the email
sendmail(mail,'Test from MATLAB','Hello! This is a test from MATLAB!')
But I keep on getting this error:
Error using sendmail (line 171)
Authentication failed.
Any ideas what might be causing this? How do I get passed it?

Risposta accettata

mizuki il 2 Nov 2016
Check the following two things:
1. Change the variable host as
host = '';
  1 Commento
Iddo Weiner
Iddo Weiner il 2 Nov 2016
Modificato: Iddo Weiner il 2 Nov 2016
The "gmail" was a typo, but the second suggestion worked. I thought I already adjusted my account for allowing less secure apps but apparently I didn't do it correctly.
Now it works :) thanks

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by