how to use sendmail with office365 email account
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I failed to use sendmail in combination with an office365 account.
I used the code below:
smtp = 'smtp.office365.com';
port = '587';
user = 'myusername@something.com';
psswd = 'mypassword';
emailto = 'someaddress@something.com';
subject = 'test';
text = 'test';
setpref( 'Internet', 'SMTP_Server', smtp );
setpref( 'Internet', 'SMTP_Username', user );
setpref( 'Internet', 'SMTP_Password', psswd );
props = java.lang.System.getProperties;
props.setProperty( 'mail.smtp.user', user );
props.setProperty( 'mail.smtp.host', host );
props.setProperty( 'mail.smtp.port', port );
props.setProperty('mail.smtp.auth', 'true');
props.setProperty('mail.smtp.starttls.enable', 'true');
props.setProperty('mail.smtp.socketFactory.port', port);
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
sendmail(emailto , subject, text);
It gives this error:
Error using sendmail (line 172)
Could not connect to SMTP host: smtp.office365.com, port: 587;
Connection refused: connect
Note that with the same code I have managed to send an email using a gmail account (using server:smtp.gmail.com and port:465)
Is it something I can fix via matlab or is it an office365 specific problem ?
matlab version: Matlab R2013b
1 Kommentar
Markus Hohlagschwandtner
am 26 Nov. 2022
My solution was this line:
props.setProperty('mail.smtp.auth', 'false');
Antworten (2)
Tobias Riedener
am 8 Mär. 2018
What happened to this problem?? Looking into exactly the same...
0 Kommentare
Siehe auch
Kategorien
Mehr zu Web Services finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!