CZ-NIC / envelope

Insert a message and attachments and send e-mail / sign / encrypt contents by a single line.
Other
171 stars 12 forks source link

Check email send succesfully not possible. #12

Closed unicode-it closed 2 years ago

unicode-it commented 3 years ago

Docstring of send-method: To check e-mail was successfully sent, cast the returned object to bool.

Expected behaviour:

check = Envelope().send()
if not check:
    raise SomeException

Should raise SomeException if send fails.

Actual behaviour:

No way to check if sending was succesfull. No Exception raised.

unicode-it commented 3 years ago

See pull request.

e3rd commented 3 years ago

Hi, could you please further prove actual behaviour does not work? It seems to my SomeException is correctly raised when sending fails now. Thanks!

unicode-it commented 3 years ago

I tried the following: I set a wrong sender address to test it. The smtp server refused to send the mail. The error was correctly logged via logger. But the check still evaluated to true. I actually oversaw the implementation of __bool__ method, but still it does not evaluate to false even though the message is not send.

e3rd commented 3 years ago

check still evaluated to true

Post the code you've tried please. I wonder to see how come it evaluated to True.

from envelope import Envelope
e = Envelope("dummy")
print(bool(e))  # False

e.to("test@example.com")
print(bool(e))  # False

e.sender(False)
e.send()
print(bool(e))  # False
e3rd commented 2 years ago

No reaction, closing for now