Created
April 1, 2016 16:24
-
-
Save andyhasit/f14e40908ded5bab7dd27d1d91a9ba57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Place this in a controller and call it, either by url or directly from code. | |
An email(or multiple) with the correct settings will be sent to the | |
test address. | |
''' | |
def test_mail(): | |
bases = ['yourdomain.com', 'yourhosting.company.net'] | |
prefixes = ['smtp.', 'mail.', ''] | |
ports = [':25' ':465', ':993', ':587', ''] | |
sender = '[email protected]' | |
login = '[email protected]:password' | |
send_test_to = '[email protected]' | |
count = 0 | |
mail.settings.tls = True #Here so you can set to False if things fail? | |
for base in bases: | |
for prefix in prefixes: | |
for port in ports: | |
server = '{0}{1}{2}'.format(prefix, base, port) | |
msg = 'server: {0} login: {1}'.format(server, login) | |
# So you can correlate with error codes. Note some servers don't like print! | |
print msg | |
mail.settings.server = server | |
mail.settings.sender = sender | |
mail.settings.login = login | |
mail.send(to=[send_test_to], | |
subject='hello', | |
reply_to='[email protected]', | |
message=msg | |
) | |
count += 1 | |
return dict(message="tried {0} combinations".format(count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment