Friday, 15 July 2011

python - Sending emails with Django and Post Office -


I have some difficulty in setting up email options for my own project. I am using the post office for backend, But I can not find anything for the queue.

From the django.views.generic Import TemplateView Post_office Import Mail Class EmailView (templateview) from views.py:

 : Model = Customer Mail Send ('a.sophiewirth@gmail.com', # Email address list also accepted 'your.generic.test.email@gmail.com', subject = 'my email', message = '! Hi', html_message = 'Hi & lt; strong & gt; There & lt; / strong & gt;!',) TEMPLATE_NAME = 'Customers / send_email.html'  

settings.py.

  as the default email backend EMAIL_BACKEND = 'post_office.EmailBackend' POST_OFFICE = using Post # { 'DEFAULT_PRIORITY': 'now'} EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = "your. generic.test.email@gmail.com "EMAIL_PORT = 25 # default SMTP port EMAIL_HOST_PASSWORD =" password "EMAIL_USE_TLS = false DEFAULT_FROM_EMAIL = 'your.generic.test.email@gmail.com'  

Urls .py:

import patterns from django.conf.urls, include, URL from customers. View Import View from CustomerList, CreateCustomerView, CustomerUpdateView, Email. Import ideas urlpatterns = patterns ( 'url (r' ^ $ ', CustomerListkas_view (), name = "customer list"), url (r' ^ make-customer $ 'CreateCustomerViewkas_view (), Name = " make-customer "), url (r '^ client update / (P & LT ;? pk & gt; \ d +) $', CustomerUpdateView.as_view (), name =" customer update "), url (r '^ Send -mail $ ', EmailView.as_view (), name = "send-email"),)

send_email.html itself is far too far away, it just tells you one The paragraph is that you have sent an email.

Can anyone tell me why is not sending? Also, how can I receive the recipient as an exclusive user in the email?

Thank you very much :)

I have more installed it is an old project And I believe that the DJCL is no longer needed, but my setup is still giving you a start.

  import djcelery ... djcelery.setup_loader () EMAIL_BACKEND = 'post_office.EmailBackend' POST_OFFICE_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'   

My project also includes a shell script, which I run to start and configure celery daemon. Something is going on in my project, so this may not be necessary for you.

  #! / Bin / bash set -e # User / Group USER = GROUP run as your_username = your_groupname cd / Path / to / virtualenv / source ./bin/activate cd /path/to/directory/containing/manage.py / Exec The python manage.py celeryd --settings = directory.path.settings.py  

Running a shell script shows you the running vegetable process and sending your emails now and cheered happily .


No comments:

Post a Comment