IOException with sendmail: Connection reset by peer: socket write error
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I get the following error when using sendmail.m (R2010b):
IOException while sending message:
Connection reset by peer: socket wrtie error
This does not happen all the times, but very frequently when I try to send consecutive emails through an automated script.
Example code:
% send 3 email with attachments
for email_counter=1:3
recipient = 'example@gmail.com';
message = [' ' 10 'Docs attached'];
subject = 'docs';
sender = 'example@gmail.com';
psswd = 'password';
attachments = {'doc1.pdf', 'doc2'};
setpref('Internet','E_mail',sender);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',sender);
setpref('Internet','SMTP_Password',psswd);
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');
sendmail(recipient, subject, message, attachments);
end
Typically, by email number 2 the script would crash and throw an exception.
Any help?
0 commentaires
Réponses (1)
Varun Bhaskar
le 10 Août 2015
Hello,
Since you are observing the above error only when you call the ‘sendmail’ function in a loop, try the following steps:
1) Disable anti-virus.
2) Include a pause of 5s after the ‘sendmail’ call in each iteration of the loop to ensure that one call is completed before the next one is invoked in the following manner:
pause(5)
Voir également
Catégories
En savoir plus sur Web Services dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!