AppScale / gts

AppScale is an easy-to-manage serverless platform for building and running scalable web and mobile applications on any infrastructure.
https://www.appscale.com/community/
Apache License 2.0
2.42k stars 277 forks source link

Email sending failed #2341

Open khaledkbadr opened 7 years ago

khaledkbadr commented 7 years ago

Our app sends emails for authentication purposes, but when it starts sending it shows that error and prevent email from being sent.

  File "/usr/lib/python2.7/smtplib.py", line 793, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout)
  File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 316, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 799, in _get_socket
    new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
  File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 209, in __init__
    if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
  File "/root/appscale/AppServer/google/appengine/dist27/socket.py", line 222, in meth
    return getattr(self._sock,name)(*args)
  File "/root/appscale/AppServer/google/appengine/api/remote_socket/_remote_socket.py", line 1094, in getsockopt
    raise _SystemExceptionFromAppError(e)
error: [Errno 22] Invalid argument

We've temporarily fixed this by replacing socket.py with the original python's socket.py

cdonati commented 7 years ago

How are you sending the email? Is it the standard google.appengine.api.mail library, or Python's smtplib?

khaledkbadr commented 7 years ago

We're using Python's smtplib for that

cdonati commented 7 years ago

I would recommend using google.appengine.api.mail. As far as I know, using smtplib is not supported in App Engine. See https://groups.google.com/forum/#!topic/appscale_community/_uC88tl6DKU for setting up msmtp.

FastGeert commented 7 years ago

The problem is not about how we send emails, but rather that the socket api does not work unless we patch the socket.py module. https://cloud.google.com/appengine/docs/standard/python/sockets/