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

Allow address.parse() to reject addresses with local hostnames #201

Open
grvsmth opened this issue Jun 7, 2018 · 6 comments
Open

Allow address.parse() to reject addresses with local hostnames #201

grvsmth opened this issue Jun 7, 2018 · 6 comments

Comments

@grvsmth
Copy link

grvsmth commented Jun 7, 2018

address.parse() currently accepts addresses with a single-part domain as used for a local mail host, e.g. bleah@example. I am currently working on a use case where we would only want to send to Internet addresses, like [email protected] or [email protected]. It would be useful to have an option to reject addresses with single-part domains.

@horkhe
Copy link
Member

horkhe commented Jun 8, 2018

It seems to be too use case specific to be included as a parser option. I can think of many similar specific use cases e.g.: do not allow domains of 3rd, 4th, Xth level; do not allow domains from specific top level domains; do not allow domains from a certain geo region... All that seems like a higher level of abstraction that lays out of the scope of the email address syntax parsing.

In your case the solution is as simple as:

addr = parse('bleah@example')
if addr and '.' in add.hostname:
    // bingo
else:
    // invalid address or local domain 

So I think it is out of the scope of Flanker and should not be implemented. @b0d0nne11 what do you think?

@b0d0nne11
Copy link
Contributor

I would agree. There maybe other users of the library that have a valid use case to send to bob@localhost for example.

@grvsmth
Copy link
Author

grvsmth commented Jun 8, 2018

To clarify, Brendan, I am not suggesting we remove the validation of addresses like blah@example. I am suggesting we add the option to filter out addresses with that form.

@grvsmth
Copy link
Author

grvsmth commented Jun 8, 2018

Thanks for your feedback, Maxim. I do not see the other use cases you mention as being anywhere near as common, and I hope you will consider adding this option. In the meantime I will add a check in my script along the lines you suggest.

@b0d0nne11
Copy link
Contributor

b0d0nne11 commented Jun 8, 2018

Actually validate_address should already reject blah@example and bob@localhost because they don't have a valid TLD. It will also optionally lookup the MX servers and try to connect to them but that can be turned off with the skip_remote_checks kwarg. We use that in our messages API after parsing to filter out these kinds of addresses.

@grvsmth
Copy link
Author

grvsmth commented Jun 8, 2018

We don't really want to go to the trouble of calling validate_address() when all we want is to check the form of the address, but thanks.

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