开发者

Sending email from dev server with --smtp_host=smtp.gmail.com

开发者 https://www.devze.com 2023-01-25 21:24 出处:网络
In the answer to the question Error sending e-mail via SMTP server on App Engine development server there is a nice solution by Blixt:

In the answer to the question Error sending e-mail via SMTP server on App Engine development server there is a nice solution by Blixt:

"dev_appserver.py does not support TLS 
which is required by Gmail. You can 
enable it by adding a few lines in api/mail_stub.py:"

# After smtp.connect(self._smtp_host, self._smtp_port)
smtp.ehlo()
smtp.starttls()
smtp.ehlo()

But windows Vista would not let me change api/mail_stub.py

Is there another way to send mail from development server. Other options (Sendmail and ISP are not good for me). Thanks!

EDIT

I changed the api/mail_stub.py according to instructions here and I use the following command-line options:

dev_appserver.py  
--smtp_host=smtp.gmail.com 
--smtp_port=25 
--smtp_user=xxxx@gmail.com 
--smtp_password=gmail_pw 
C:\Users\A\Desktop\repeater # path to root directory

But I get this error from Log Console:

***********************************************************
2010-11-18 10:24:37 Running command: "['C:\\Python26\\pythonw.exe', 
'C:\\Program Files(x86)\\Google\\google_appengine\\dev_appserver.py', 
'--admin_console_server=', 
'--port=8080', 
u'dev_appserver.py', 
u'--smtp_host=smtp.gmail.com', 
u'--smtp_port=25', 
u'--smtp_user=xxxx@gmail.com', 
u'--smtp_password=gmail_pw 
C:\\Users\\A\\Desktop\\repeater', 
'C:\\Users\\A\\Desktop\\repeater']"

Runs a development application server for an application.

dev_appserver.py [options] &开发者_StackOverflow社区lt;application root>

Application root must be the path to the application to run in this server.
Must contain a valid app.yaml or app.yml file.

****************************************************

This is the app.yaml:

application: re-peater
version: 1
runtime: python
api_version: 1

handlers:

- url: /favicon.ico
  static_files: static/images/favicon.ico
  upload: static/images/favicon.ico

- url: /stylesheets
  static_dir: stylesheets

- url: /.*
  script: repeater.py

All this works without these command line options. Any suggestions why this is not working?


If you really, really need to send real email from the dev_appserver, you should set up your own mail relay on your machine, and point the SDK at that. I'm curious why it's so important to send real email, though - this is the development server, and you shouldn't be using it for anything other than development.


Change the file permissions so that you can change the api/mail_stub.py file.


This is no longer necessary

in /appengine/api/mail_stub.py

if self._allow_tls and smtp.has_extn ('STARTTLS'): smtp.starttls ()

I am using appengine sdk version 1.9.15.

0

精彩评论

暂无评论...
验证码 换一张
取 消