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

Error report while start my application #253

Open
ThrowSyntaxError opened this issue Sep 8, 2022 · 4 comments
Open

Error report while start my application #253

ThrowSyntaxError opened this issue Sep 8, 2022 · 4 comments

Comments

@ThrowSyntaxError
Copy link

here is some error message:
Exception ignored in: <function SMTP.del at 0x7f60bed18430>

Traceback (most recent call last):
  File "/root/anaconda3/envs/yixing_39/lib/python3.8/site-packages/yagmail/sender.py", line 261, in __del__
  File "/root/anaconda3/envs/yixing_39/lib/python3.8/site-packages/yagmail/sender.py", line 203, in close
TypeError: catching classes that do not inherit from BaseException is not allowed

description:
I'm gonna test the function of sending email by using yagmail module in my app,but when I running my project the above problem occurred. dose it exist an error in source code? or just my fault? How should I solve this problem?

here is the code for the corresponding location above:

 def close(self):
        """ Close the connection to the SMTP server """
        self.is_closed = True
        try:
            self.smtp.quit()
        except (TypeError, AttributeError, smtplib.SMTPServerDisconnected):  # line 203
            pass
@kootenpv
Copy link
Owner

kootenpv commented Sep 8, 2022

How are you using yagmail

@ThrowSyntaxError
Copy link
Author

你如何使用亚格邮件

I smply use it just like this

 class mailManager:
     def __init__(self):
         self.User = '[email protected]'
         self.PassWord = '**********'
         self.SMTPClient = yagmail.SMTP(
             host='smtp.EmailServer.com',
             user=self.User,
             password=self.PassWord,
             port=465
         )

     def sendMail(self, receiver, subject, text):
         try:
             self.SMTPClient.send(receiver, subject, text)
             print("Successfully sending e-mail!")
         except Exception:
             print("Error while sending e-mail:", Exception)

@kootenpv
Copy link
Owner

kootenpv commented Sep 8, 2022

Try creating the smtp client right before sending all the time

@ThrowSyntaxError
Copy link
Author

Try creating the smtp client right before sending all the time

Acturally I just create a new mialManager instance in file app.py and not using sendMail function yet. I've switched to smptlib module in my app temporarily, but I still wanna figure it out. I notice that sometimes you need create a connection by using smtplib.SMTP_SSL() instead of smtplib.SMTP() in smtplib module, is this one of the possible reasons?

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

2 participants