【问题标题】:Unable to send mail using celery with kombu as broker无法使用 celery 和 kombu 作为代理发送邮件
【发布时间】:2016-01-01 19:37:23
【问题描述】:

我是 celery 的新手,尝试发送电子邮件但我无法接收邮件。

settings.py

import djcelery
djcelery.setup_loader()
BROKER_URL = 'django://'

INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'raven.contrib.django.raven_compat',
'simple_pagination',
'haystack',
'pmt_admin',
'pmt_site',
'django_nose',
'social',
'djcelery',
'kombu.transport.django',
'endless_pagination',
'compressor',

)

EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'Company Name'
EMAIL_HOST_PASSWORD = 'xxxxxxxx'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

tasks.py

from celery import task
from django.core.mail import send_mail

@task()
def smail():
send_mail("celery_testing", "Celery worked", "Company Name",
    ["tomail@gmail.com"], fail_silently=False)

python manage.py shell

>>> smail.delay()
<AsyncResult: be15f163-d18d-40f6-b6f9-c3de3a6aa342>

当我运行 kombu 代理时 python manage_local.py celery worker --loglevel=info 我收到类似的错误

【问题讨论】:

    标签: python django django-celery kombu


    【解决方案1】:

    我认为此时您的问题不在于 Kombu。看来这个 ImportError 是因为你没有在 INSTALLED_APPS mpcomp app 上指定。

    试试:

    INSTALLED_APPS += ('mpcomp',)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 2020-04-20
      • 2019-06-04
      相关资源
      最近更新 更多