Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smtplib.SMTPServerDisconnected: please run connect() #43

Closed
steve2072 opened this issue May 1, 2016 · 6 comments
Closed

smtplib.SMTPServerDisconnected: please run connect() #43

steve2072 opened this issue May 1, 2016 · 6 comments

Comments

@steve2072
Copy link

Hi. When trying to send with a mail within a with section and with a body and an HTML file attached, I have this error.

Exception ignored in: <bound method SMTP.__del__ of <yagmail.yagmail.SMTP object at 0x101f08c18>>
Traceback (most recent call last):
  File "/Users/Steve/Library/Python/3.5/lib/python/site-packages/yagmail/yagmail.py", line 388, in __del__
    self.close()
  File "/Users/Steve/Library/Python/3.5/lib/python/site-packages/yagmail/yagmail.py", line 131, in close
    self.smtp.quit()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/smtplib.py", line 974, in quit
    res = self.docmd("quit")
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/smtplib.py", line 419, in docmd
    self.putcmd(cmd, args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/smtplib.py", line 366, in putcmd
    self.send(str)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/smtplib.py", line 358, in send
    raise SMTPServerDisconnected('please run connect() first')
smtplib.SMTPServerDisconnected: please run connect() first
@kootenpv
Copy link
Owner

kootenpv commented May 1, 2016

Hi, thanks for taking the time to post an issue. Could you provide some example code? I cannot reproduce by with + body + html file attached.

@steve2072
Copy link
Author

steve2072 commented May 1, 2016

Hi,

Thx for your prompt reply.

I managed to fix it by not using the with section. The code ends without any error message (LEVEL=DEBUG), which seems normal as I don’t properly close the connection (following the hints of the doc).

The code is quite simple and really isn’t worth being sent. Maybe it is related to new GMail settings ?

Regards,

PS : btw, I am using Airmail on Mac. The HTML (see attached), which is an email signature, is attached to the email sent. It is well displayed in Airmail Client as an HTML body (which is ok) and also as a file attached but this one is continuously trying to download it and cannot be opened. In my former code, which is a step by step process for using Gmail (that’s why I was trying your very convenient library), I did not have this issue. When using Mail App on Mac, everything works in both cases. I know you are not supposed to support Airmail but maybe it may give you some hints about anything.

Le 1 mai 2016 à 22:32, Pascal van Kooten notifications@github.com a écrit :

Hi, thanks for taking the time to post an issue. Could you provide some example code? I cannot reproduce by with + body + html file attached.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub #43 (comment)

@bepetersn
Copy link

bepetersn commented Sep 9, 2016

Seeing this error also. It looks like __del__ is getting called after the connection is already closed. It tries to close after already being closed, and this error is produced.

Could be easily made not to occur by checking if is_closed before closing in __del__, though honestly I have no idea why it's happening for me right now.

@kootenpv
Copy link
Owner

kootenpv commented Sep 9, 2016

Wow, when you write "fixes and issue number" it closes automatically....

@bepetersn
Copy link

@kootenpv Yup, haha. Thanks for adding so quickly.

@kootenpv
Copy link
Owner

kootenpv commented Sep 9, 2016

@steve2072 It appears my comment to you hadn't gone through. I'm not exactly sure what the problem/error is, but if you provide an example perhaps it can be fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants