No valid exception for knowing 'Access Denied' #44

Closed
opened 2021-02-07 12:58:09 +01:00 by voxvici · 8 comments
voxvici commented 2021-02-07 12:58:09 +01:00 (Migrated from github.com)

Exception 'AddressNotDeliverableError' is thrown both for when a server is blocked/denied and when email doesn't exist.

Gmail allows local testing if you run the following code

try:
    is_valid = validate_email_or_fail(email_address='this.is.my.name.new.name3@gmail.com', check_regex=False, check_mx=True, use_blacklist=True, debug=True)
except Exception as ex:
    message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}"
    print(message)

Inside Debug Log it will emit 'The email account that you tried to reach does not exist'

Outlook disallows local testing if you run the following code

try:
    is_valid = validate_email_or_fail(email_address='this.is.my.name.new.name3@primaplan.nl', check_regex=False, check_mx=True, use_blacklist=True, debug=True)
except Exception as ex:
    message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}"
    print(message)

Inside Debug Log it will emit 'Access denied, banned sending IP'

'AddressNotDeliverableError' exception cannot be both if a server got blocked and email doesn't exist.

Exception 'AddressNotDeliverableError' is thrown both for when a server is blocked/denied and when email doesn't exist. Gmail allows local testing if you run the following code ``` try: is_valid = validate_email_or_fail(email_address='this.is.my.name.new.name3@gmail.com', check_regex=False, check_mx=True, use_blacklist=True, debug=True) except Exception as ex: message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}" print(message) ``` Inside Debug Log it will emit 'The email account that you tried to reach does not exist' Outlook disallows local testing if you run the following code ``` try: is_valid = validate_email_or_fail(email_address='this.is.my.name.new.name3@primaplan.nl', check_regex=False, check_mx=True, use_blacklist=True, debug=True) except Exception as ex: message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}" print(message) ``` Inside Debug Log it will emit 'Access denied, banned sending IP' 'AddressNotDeliverableError' exception cannot be both if a server got blocked and email doesn't exist.
voxvici commented 2021-02-07 13:05:44 +01:00 (Migrated from github.com)

Is it possible to access Debug object?

Is it possible to access Debug object?
manojr2k commented 2021-02-08 09:14:51 +01:00 (Migrated from github.com)

i am also interested to know the above error handling , since my code not able to understand the error code for block ip

i am also interested to know the above error handling , since my code not able to understand the error code for block ip
karolyi commented 2021-02-08 13:21:12 +01:00 (Migrated from github.com)

@voxvici you just have to simply use the validate_email_or_fail() function, which will raise an exception that you catch and the error message will be in the exception arguments.

@voxvici you just have to simply use the `validate_email_or_fail()` function, which will raise an exception that you catch and the error message will be in the exception arguments.
reinhard-mueller commented 2021-02-10 20:08:55 +01:00 (Migrated from github.com)

@manojr2k @voxvici Out of curiosity, may I ask what you would consider the best behavior in the case of such an "Access denied" (or other messages about blacklisting or similar issues)?

Would it be sufficient if the result of the function was just None like in other cases where there is no verification possible (like mail server down, greylisting etc), and you can look at the debug log what was the reason for not being able to give a clear result? Or would you still need access to the error messages to programmatically react different to the various reasons that can lead to a None result? Or would you think an additional exception should be introduced saying "you're blacklisted"?

@manojr2k @voxvici Out of curiosity, may I ask what you would consider the best behavior in the case of such an "Access denied" (or other messages about blacklisting or similar issues)? Would it be sufficient if the result of the function was just `None` like in other cases where there is no verification possible (like mail server down, greylisting etc), and you can look at the debug log what was the reason for not being able to give a clear result? Or would you still need access to the error messages to programmatically react different to the various reasons that can lead to a `None` result? Or would you think an additional exception should be introduced saying "you're blacklisted"?
manojr2k commented 2021-02-11 12:38:45 +01:00 (Migrated from github.com)

There should be some unique id which we can identify in the code and take
the necessary action

On Thu, Feb 11, 2021 at 12:39 AM Reinhard Müller notifications@github.com
wrote:

@manojr2k https://github.com/manojr2k @voxvici
https://github.com/voxvici Out of curiosity, may I ask what you would
consider the best behavior in the case of such an "Access denied" (or other
messages about blacklisting or similar issues)?

Would it be sufficient if the result of the function was just None like
in other cases where there is no verification possible (like mail server
down, greylisting etc), and you can look at the debug log what was the
reason for not being able to give a clear result? Or would you still need
access to the error messages to programmatically react different to the
various reasons that can lead to a None result? Or would you think an
additional exception should be introduced saying "you're blacklisted"?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/karolyi/py3-validate-email/issues/44#issuecomment-776942706,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AISU5BNCRGAD2YKP6OPMUKTS6LKVXANCNFSM4XHL55NA
.

There should be some unique id which we can identify in the code and take the necessary action On Thu, Feb 11, 2021 at 12:39 AM Reinhard Müller <notifications@github.com> wrote: > @manojr2k <https://github.com/manojr2k> @voxvici > <https://github.com/voxvici> Out of curiosity, may I ask what you would > consider the best behavior in the case of such an "Access denied" (or other > messages about blacklisting or similar issues)? > > Would it be sufficient if the result of the function was just None like > in other cases where there is no verification possible (like mail server > down, greylisting etc), and you can look at the debug log what was the > reason for not being able to give a clear result? Or would you still need > access to the error messages to programmatically react different to the > various reasons that can lead to a None result? Or would you think an > additional exception should be introduced saying "you're blacklisted"? > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/karolyi/py3-validate-email/issues/44#issuecomment-776942706>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AISU5BNCRGAD2YKP6OPMUKTS6LKVXANCNFSM4XHL55NA> > . >
manojr2k commented 2021-02-19 09:04:01 +01:00 (Migrated from github.com)

any update reinhard ?

any update reinhard ?
reinhard-mueller commented 2021-02-19 09:19:53 +01:00 (Migrated from github.com)

@manojr2k sorry I don't think that I will have an implementation proposal in short time, I need to think more about this, but your feedback is appreciated as input for that.

@manojr2k sorry I don't think that I will have an implementation proposal in short time, I need to think more about this, but your feedback is appreciated as input for that.
voxvici commented 2021-02-19 20:24:50 +01:00 (Migrated from github.com)

@reinhard-mueller
apologizes for not answering been busy with work, I've found a workaround solution for the blacklist issue ideally a blacklist exception but I've read some of the @karolyi comments before and he was talking it's hard to know when the server actually is blacklisted? if I remember correctly. It would be nice to have an additional exception due to logging and knowing what is internally happening without having to access debug

EDIT right now I've seen the "e.error_messages will be a list of error messages" comment on one of the issues, missed that one. Great work and thank you for answering to issue and updating the module

@reinhard-mueller apologizes for not answering been busy with work, I've found a workaround solution for the blacklist issue ideally a blacklist exception but I've read some of the @karolyi comments before and he was talking it's hard to know when the server actually is blacklisted? if I remember correctly. It would be nice to have an additional exception due to logging and knowing what is internally happening without having to access debug **EDIT** right now I've seen the "e.error_messages will be a list of error messages" comment on one of the issues, missed that one. Great work and thank you for answering to issue and updating the module
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: karolyi/py3-validate-email#44
No description provided.