Borrar filtros
Borrar filtros

IOException with sendmail: Connection reset by peer: socket write error

5 visualizaciones (últimos 30 días)
joeDiHare
joeDiHare el 9 de Ag. de 2015
Comentada: joeDiHare el 10 de Ag. de 2015
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?

Respuestas (1)

Varun Bhaskar
Varun Bhaskar el 10 de Ag. de 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)
  1 comentario
joeDiHare
joeDiHare el 10 de Ag. de 2015
Hi Varun, thanks for your reply.
The problem occurs also, sometimes, for single instances of sendmail.
I had tried to use the pause command before without luck.
Instead, disabling the anti-virus seems to reduce the problem. I wonder why?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by