flask-mail TypeError: getaddrinfo() argument 1 must be string or None

Žan Fras

I want to use flask mail in my webapp and I am gettin error that I don't really understand. Been following guidelines and can't get it to work. In the following proccess I want app to send email to new registered user.

Config:

MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
MAIL_USE_TLS=False,
MAIL_USERNAME = '[email protected]',
MAIL_PASSWORD = '******'

View:

from flask_mail import Mail, Message
mail = Mail(app)


@app.route("/send_mail/")
def send_mail():
   msg = Message('Hello', sender = '[email protected]', recipients = ['[email protected]'])
   msg.body = "This is the email body"
   mail.send(msg)

Error I am getting:

File "C:\venvs\test\lib\site-packages\flask\app.py", line 1994, in __call__
return self.wsgi_app(environ, start_response)
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\venvs\test\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\venvs\test\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "C:\venvs\test\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\venvs\test\views.py", line 202, in send_mail
mail.send(msg)
File "C:\venvs\test\lib\site-packages\flask_mail.py", line 491, in send
with self.connect() as connection:
File "C:\venvs\test\lib\site-packages\flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "C:\venvs\test\lib\site-packages\flask_mail.py", line 156, in configure_host
host = smtplib.SMTP_SSL(self.mail.server, self.mail.port)
File "C:\Python\lib\smtplib.py", line 1029, in __init__
source_address)
File "C:\Python\lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python\lib\smtplib.py", line 335, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python\lib\smtplib.py", line 1035, in _get_socket
self.source_address)
File "C:\Python\lib\socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python\lib\socket.py", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
TypeError: getaddrinfo() argument 1 must be string or None

Any ideas?

Matt Healy

Your settings in your config file seem to have a trailing comma, which would make them tuples. Flask-Mail is complaining that the host value passed in to getaddrinfo is not a string - it's most likely a tuple.

Removing the trailing commas may fix this issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting TypeError: type() argument 1 must be string, not None

From Dev

Getting TypeError: type() argument 1 must be string, not None

From Dev

TypeError: decode() argument 1 must be str, not None

From Dev

python TypeError: argument 1 must be string or read-only character buffer, not None

From Dev

TypeError: argument 1 must be string or read-only character buffer, not None

From Dev

When trying to request for OAuth access_token I get: TypeError: encode() argument 1 must be string, not None

From Dev

Assistance with TypeError:write() argument must be str, not None

From Dev

unicode() argument 2 must be string not None

From Dev

TypeError: float() argument must be a string or a number, not 'Tensor'

From Dev

TypeError: float() argument must be a string or a number, not 'IntVar'

From Dev

TypeError: write() argument 1 must be unicode, not str

From Dev

TypeError: strptime() argument 1 must be str, not Series

From Dev

TypeError: file() argument 1 must be encoded string without NULL bytes, not str odoo

From Dev

Training '\x00' s and TypeError: stat() argument 1 must be encoded string without null bytes, not str

From Dev

TypeError: argument 1 must be string or read-only character buffer, not file (in exercise 17 of Learn python the Hard)

From Dev

Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, string given in

From Dev

What causes "elasticsearch.exceptions.ConnectionError: ConnectionError ... error('getaddrinfo() argument 2 must be integer or string',)))

From Dev

Argument 1 must be string, not datetime.datetime?

From Dev

Django TypeError int() argument must be a string or a number, not 'QueryDict'

From Dev

TypeError: float() argument must be a string or a number in Django distance

From Dev

TypeError: int() argument must be a string or a number, not 'datetime.datetime'

From Dev

Django Error: TypeError: int() argument must be a string or a number, not 'BuildsTable'

From Dev

TypeError: int() argument must be a string or a number, not 'Model Instance'

From Dev

throw message; TypeError: first argument must be a string or Buffer

From Dev

TypeError: Float() argument must be a string or a number when reading a list()

From Dev

TypeError: float() argument must be a string or a number with list sum

From Dev

TypeError: float() argument must be a string or a number, not 'list' python

From Dev

Django - TypeError: int() argument must be a string or a number, not 'dict'

From Dev

Getting "TypeError: float() argument must be a string or a number" with pandas plot()

Related Related

  1. 1

    Getting TypeError: type() argument 1 must be string, not None

  2. 2

    Getting TypeError: type() argument 1 must be string, not None

  3. 3

    TypeError: decode() argument 1 must be str, not None

  4. 4

    python TypeError: argument 1 must be string or read-only character buffer, not None

  5. 5

    TypeError: argument 1 must be string or read-only character buffer, not None

  6. 6

    When trying to request for OAuth access_token I get: TypeError: encode() argument 1 must be string, not None

  7. 7

    Assistance with TypeError:write() argument must be str, not None

  8. 8

    unicode() argument 2 must be string not None

  9. 9

    TypeError: float() argument must be a string or a number, not 'Tensor'

  10. 10

    TypeError: float() argument must be a string or a number, not 'IntVar'

  11. 11

    TypeError: write() argument 1 must be unicode, not str

  12. 12

    TypeError: strptime() argument 1 must be str, not Series

  13. 13

    TypeError: file() argument 1 must be encoded string without NULL bytes, not str odoo

  14. 14

    Training '\x00' s and TypeError: stat() argument 1 must be encoded string without null bytes, not str

  15. 15

    TypeError: argument 1 must be string or read-only character buffer, not file (in exercise 17 of Learn python the Hard)

  16. 16

    Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, string given in

  17. 17

    What causes "elasticsearch.exceptions.ConnectionError: ConnectionError ... error('getaddrinfo() argument 2 must be integer or string',)))

  18. 18

    Argument 1 must be string, not datetime.datetime?

  19. 19

    Django TypeError int() argument must be a string or a number, not 'QueryDict'

  20. 20

    TypeError: float() argument must be a string or a number in Django distance

  21. 21

    TypeError: int() argument must be a string or a number, not 'datetime.datetime'

  22. 22

    Django Error: TypeError: int() argument must be a string or a number, not 'BuildsTable'

  23. 23

    TypeError: int() argument must be a string or a number, not 'Model Instance'

  24. 24

    throw message; TypeError: first argument must be a string or Buffer

  25. 25

    TypeError: Float() argument must be a string or a number when reading a list()

  26. 26

    TypeError: float() argument must be a string or a number with list sum

  27. 27

    TypeError: float() argument must be a string or a number, not 'list' python

  28. 28

    Django - TypeError: int() argument must be a string or a number, not 'dict'

  29. 29

    Getting "TypeError: float() argument must be a string or a number" with pandas plot()

HotTag

Archive