Closed manojr2k closed 3 years ago
+
Having access to status code and debug object would be nice
do you know how we can have a access to status code?
It's inaccessible from my knowledge. I'll look into making a custom solution because this module isn't production ready
If you use validate_email_or_fail() you should get the exception instead of just False
, and if the exception is AddressNotDeliverableError
you should get the error messages from the server in the error_messages
property.
Hi reinhard
thanks for the reply , can you please show some example ? that will be very helpful
try: host = socket.gethostname()
is_valid = validate_email_or_fail(email_address=abc@abc.com, check_regex=True, check_mx=True, from_address='xyz@gmail.com', helo_host=host, smtp_timeout=10, dns_timeout=10, use_blacklist=False, debug=True)
logger.debug(addressToVerify + " => Response-Code " + str(is_valid))
except Exception: logger.debug(Exception)
do you mean to say this way ?
from validate_email import validate_email_or_fail
from validate_email.exceptions import AddressNotDeliverableError
try:
validate_email_or_fail("user@domain.org", from_address="myself@gmail.com", helo_host="myhostname")
except AddressNotDeliverableError as e:
print(e.error_messages)
e.error_messages
will be a list of error messages, one for each mail server for the domain. The error messages are strings in the format mail.domain.org.: 550 5.1.1 The email account that you tried to reach does not exist.
.
Thanks for the example reinhard
with the code below exceptions are not printing 553 delivery from xx.xxx.xx.xxx is rejected. The connecting IP is blocked using zen.spamhaus.org 550 5.7.606 Access denied, banned sending IP
i can see only below exception is printing 554, b"vastu11.nic.in\nYour access to this mail system has been rejected due to the sending MTA\'s poor reputation.
@manojr2k the message you see there is what the refusing mail server gives you. you might have more MX records, and one of those is giving you exactly this message.
moreover, another possible scenario is that what you see in your server log differs from what your server shows to the client.
Hi karolyi
i m trying to check for total 8 email addresses ,and below is the response i am getting python testcheck.py m*@c***s.com ja.ta@r.com ja.tripathi@ca.co.in a.5hsd@****sd.com [] a.sd@**hs.co.in [] a@8gd.co.in ['mailgw.nic.in: (554, b"relayinsp03.nic.in\nYour access to this mail system has been rejected due to the sending MTA\'s poor reputation.")'] a@545*.co.in [] dsa@j.com []
it is looking odd, but there can be many reasons this is happening. you might have dual stack (IPv4/IPv6), you might have various MX servers, or the servers might be set up to reject email checks in a time limited fashion. all of this is up to your local network situation and the emails you want to check, and thus nothing I can fix (if there is something to fix at all), since it is nothing I can reproduce.
@manojr2k I think a possible reason for this behaviour is that the server does not even wait for the RCPT TO
keyword with the recipient email to test, but already closes the connection before that. Can you verify whether that is the case?
@manojr2k do you get a negative result for a.***sd@**hs.co.in
in your example without an exception message?
if i set debug=True while calling function validate_email_or_fail, i get below output , but print shows only [] in exception, that is what my point is.
23:47:01.934482 send: 'rcpt TO:a.***sd@**hs.co.in\r\n' 23:47:01.979897 reply: b'550 5.1.1 a.***sd@**hs.co.in User unknown\r\n' 23:47:01.980995 reply: retcode (550); Msg: b'5.1.1 a.***sd@**hs.co.in User unknown' 23:47:01.981918 send: 'quit\r\n' 23:47:02.019490 reply: b'221 mx.zoho.in closing connection\r\n' 23:47:02.020116 reply: retcode (221); Msg: b'mx.zoho.in closing connection'
You should've started with this debug log. As you see from the SMTP converstion, the email is invalid.
What's the issue then? Oh I get it now, sorry, you can't see the response from the server in the exception. I'll look into it.
23:30:12.694727 send: 'rcpt TO:j123*.tr***@sdsf**-a7**.co.in\r\n' 23:30:12.721564 reply: b'553 delivery from *...* is rejected. The connecting IP is blocked using zen.spamhaus.org; For further details, please check http://www.spamhaus.org/query/bl?ip=115.96.218.152 and contact zen.spamhaus.org to get the IP De-listed.' 23:30:12.722119 reply: retcode (553); Msg: b'delivery from ...*** is rejected. The connecting IP is blocked using zen.spamhaus.org; For further details, please check http://www.spamhaus.org/query/bl?ip=115.96.218.152 and contact zen.spamhaus.org to get the IP De-listed.' 23:30:12.722524 send: 'quit\r\n'
the above is another error which is not getting catch in exception log
@manojr2k can you tell me which version of the module you use exactly? these messages should be passed, from the current state of the module. I'm still investigating, but the messages should be passed from what I see now.
I think the bug is that _smtp_converse
and _check_one_mx
add the error message to error_messages
for codes between 400 and 499, but for codes 500 and above _smtp_converse
just returns None
(it falls off the end of the function) and so _check_one_mx
doesn't add anything to the error_messages
list. This seems to have been introduced in 35efbb7cd928d2ba916a2857ed5d5b7fc278d8b8
py3-validate-email (0.2.12) , this is what i can see for pip3 list py3-validate-email
thanks. fixing it now, expect a new version soon.
OK great thanks ,
Released 0.2.13
, try and test it please.
Hi Karolyi
thanks for the fix .. now i can see exceptions are getting logged .but just want to know about the format of exception. you can see Error code 554 is only getting displayed in the log properly. where as in 2nd case mention below , format seems to be not showing error code, can you please comment for the same.
1)Correct format 2021-02-09 03:52:10,145 ["hostmx01.logix.in: (554, b'pune2.logix.in\nIP blacklisted in http://www.senderbase.org')", "hostmx02.logix.in: (554, b'pune2.logix.in\nIP blacklisted in http://www.senderbase.org')"]
2)doubt about the below format 2021-02-09 03:52:04,534 ['mx2.zoho.in: RCPT TO failed: 5.1.1 a.s*****@*****.co.in User unknown', 'mx.zoho.in: RCPT TO failed: 5.1.1 a.s*****@*****.co.in User unknown', 'mx3.zoho.in: R CPT TO failed: 5.1.1 a.s*****@*****.co.in User unknown']
Hi Team
how i can check if my ip is blacklisted for checking email validity? ii want to grep the response code like 250, 251 , etc in variable ? currently its grepping only True , false and NONE . how i can achieve that ?