필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
joeDiHare
joeDiHare 2015년 8월 9일
댓글: joeDiHare 2015년 8월 10일
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?

답변 (1개)

Varun Bhaskar
Varun Bhaskar 2015년 8월 10일
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
joeDiHare
joeDiHare 2015년 8월 10일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by