Code Monkey home page Code Monkey logo

django-mailer's Introduction

Pinax

Table of Contents

About Pinax

Pinax is an open-source platform built on the Django Web Framework. It is an ecosystem of reusable Django apps, themes, and starter project templates. This collection can be found at http://pinaxproject.com.

Overview

This repository contains documentation for the Pinax project.

Documentation

Updating Online Documentation

The docs live online at http://pinaxproject.com/pinax/.

After a pull request is merged, checkout your local master branch:

git checkout master

Pull the update into your local master branch:

git pull origin master

Push the update live to gh-pages:

mkdocs gh-deploy

Publishing a Distribution

projects.json

distribution.json

Change Log

Contribute

For an overview on how contributing to Pinax works read this blog post and watch the included video, or read our How to Contribute section. For concrete contribution ideas, please see our Ways to Contribute/What We Need Help With section.

In case of any questions we recommend you join our Pinax Slack team and ping us there instead of creating an issue on GitHub. Creating issues on GitHub is of course also valid but we are usually able to help you faster if you ping us in Slack.

We also highly recommend reading our blog post on Open Source and Self-Care.

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a code of conduct. We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you.

Connect with Pinax

For updates and news regarding the Pinax Project, please follow us on Twitter @pinaxproject and check out our Pinax Project blog.

License

Copyright (c) 2012-2018 James Tauber and contributors under the MIT license.

django-mailer's People

Contributors

alenalato avatar alepane21 avatar alex avatar alir3z4 avatar andybak avatar bashu avatar benkonrath avatar bmihelac avatar brosner avatar davidszotten avatar dougn avatar ebdavison avatar eht16 avatar felixxm avatar frankier avatar git2samus avatar grzn avatar hartwork avatar jaap3 avatar jacinda avatar jezdez avatar jtauber avatar julienc91 avatar paltman avatar pawl avatar spookylukey avatar srtab avatar terminator14 avatar unode avatar zerok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-mailer's Issues

Aware datetime support

This needs support for aware datetimes in Django 1.5.

 venv/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:827: RuntimeWarning: DateTimeField received a naive datetime (2013-04-14 15:33:29.242280) while time zone support is active.
  RuntimeWarning)

Also, is this project still even alive? Seems like nobody's been replying to any of the issues, or been actively maintaining the code, either.

add reply_to message field

Hello,

After upgrading to django 1.8 I'm facing a problem when using this app, since django 1.8 introduced the option reply_to to EmailMessage class, but django-mailer is not using it. Is it possible to add it?

django/core/mail/message.py is firing the following error:

AttributeError: 'EmailMultiAlternatives' object has no attribute 'reply_to'

Thanks,
H.

Django110Warning: NoArgsCommand class is deprecated

Django110Warning: NoArgsCommand class is deprecated and will be removed in Django 1.10. Use BaseCommand instead, which takes no arguments by default.

occurs when
./manage.py send_mail
or
./manage.py retry_deferred

Debugging an error message when sending email with large attachments

Hi all, I've been a happy user of django-mailer for many years now but have recently run in to a problem.

I seems to have hit a limit in attachment size. The error message presents as follows:
message deferred due to failure: (452, '4.3.4 Message size exceeds fixed limit'

I'm trying to work out what underlying mechanism is returning this error, is it django/python/smtp etc. I use mandrill as my transactional email provider but the mail never seems to reach their side.

I have tried configuring postfix with different message sizes, but I'm still not sure whether that is the underlying mechanism being used here.

Any help would be much appreciated.

Duplicate Mails of the same body are being queued.

I have a post create signal registered to send emails on signup of a user only once but it seems that the messages are being queued more than once in the queue, checked it on the Django admin panel as well.

message deferred - invalid address error (can't be)

Hello,

I'm trying django-mailer just now. I'm on the phase of clearing the queue by using send_mail and retry_referred commands. I'm running them manually, without using cron yet. The e-mails are being built by a function running when I post a comment on my site. The code is fine, it has been running fine while using the normal mail backend, and I'm just posting comments on the same page, with the same logged user. However, three out of seven email messages keep being deferred, and when I try to send them again, the console error keeps saying "message deferred due to failure: {'': (501, b'5.1.3 Invalid address')}"

I really, really think that the address can't be the problem, so

  1. Is it normal to get this error, perhaps a smtp thing... if it is, how many times could it happen before the email gets through?
  2. what other problem could explain this behavior?

Thanks for any help!

Customizing password change

pip list display
Django 2.1.7
django-crispy-forms 1.7.2
pip 19.0.3
pytz 2018.9
setuptools 40.8.0
wheel 0.33.1
settings.py
import os

Build paths inside the project like this: os.path.join(BASE_DIR, ...)

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

Quick-start development settings - unsuitable for production

See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = '(ds22app=f(i441=7(=&6==8+3(n3d0x=@Bato$4mmeom4d8'

SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = []

Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
'pages',
'crispy_forms',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'newspaper_project.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'newspaper_project.wsgi.application'

Database

https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

Password validation

https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

Internationalization

https://docs.djangoproject.com/en/2.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

Static files (CSS, JavaScript, Images)

https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
AUTH_USER_MODEL = 'users.CustomUser'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
this is project struct
newspaper_project/users/templates
templates
registration
base.html
home.html
signup.html
newspaper_project/users/templates/registration
login.html
password_change_done.html
password_change_form.html

issue
login.html can display bootstrap style,password_change_done.html and password_change_form.html can not display style.I think this two page is not work.django call the default page.I do not know how to configure or modification? l am looking forward to your reply.thank you very much.

Encoding Problems

I found some problems with encoding of the title that occurred by calling admin/mailer/message/14/change/.

After adding

from django.utils.encoding import python_2_unicode_compatible

to the models.py file and the decorator to each class which contains a __str__ solved this problem.

Encode error with non unicode chars

If subject has non unicode chars, the mailer throws an encode error at the engine.py

Below my corrections on my installed package:
try: logging.info("sending message '{0}' to {1}".format( message.subject.encode("utf-8"), u", ".join(message.to_addresses).encode("utf-8")) ) except: logging.info("sending message '{0}' to {1}".format( message.subject, ", ".join(message.to_addresses)) )

smtplib.SMTPDataError 503 error blocks the entire queue in send_mail

So if there is any exception raised for one email in the Queue, all subsequent mails are essentially blocked. Often times this leads to a backlog of emails that would then need to be verified and sent. Needless to say customers gets a bit annoyed at this.

I Feel that the expected behaviour is to log the error, mark the emails as "cannot send" or something like that, and then continue with the rest of the emails.

newline characters in subject headers break the queue

hi,

I’ve just come across an exception in our error logging handler that is caused by an email header that contains newlines. The actual exception happens in engine.py#L155: BadHeaderError: Header values can't contain newlines (got '[redacted] foo\r\n bar' for header 'Subject') and is raised by djangos forbid_multi_line_headers function from django.core.mail.message. It seems like the fault is with the mail client but it would be nice if django-mailer could handle this kind of error.

My quick fix is this short function I’ve added to the mailer.models module and used as a decorator on the db_to_email function:

def normalize_subject(func):
    from functools import wraps
    import re
    @wraps(func)
    def decorator(*args, **kwargs):
        email = func(*args, **kwargs)
        if email is not None:
            email.subject = re.sub(r'[\n\r]', '', email.subject)
        return email
    return decorator

But I’m not quite sure this is the way to fix this for good. Maybe pickle allows for some preprocessing before saving the email or there is an entirely different approach I didn’t think of. If you have any idea how to move forward from this I’ll gladly work on the code and submit a pull request.

Thank you!

bug with msg.save() "null value in column 'id'"

I have django-mailer running on a live install and on a local dev install without problems but on a second dev install with same code I get this error when django-mailer tries to msg.save()
null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, gANjZGphbmdvLmNvcmUubWFpbC5tZXNzYWdlCkVtYWlsTXVsdGlBbHRlcm5hdGl2..., 2018-12-11 09:22:30.902662+00, 2).

Any help to track down what is happening is very welcome!

send_mail(): LockFailed

Hi,

I offloaded the mail sending proces to a celery task and I ran into LockFailed when running it from a user that is not permitted to write to the current directory:

[2016-12-28 14:14:00,091: ERROR/PoolWorker-2] Task app.send_email[bc0a43ba-b2cc-4131-bda2-30722665ee4a] raised unexpected: LockFailed('failed to create /var/www/brownpapersession/demo/brownpapersession/xxxxx-vps-76199700.114845734606605386126845',)
Traceback (most recent call last):
  File "/var/www/brownpapersession/demo/env-brownpapersession/local/lib/python2.7/site-packages/celery/app/trace.py", line 367, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/var/www/brownpapersession/demo/env-brownpapersession/local/lib/python2.7/site-packages/celery/app/trace.py", line 622, in __protected_call__
    return self.run(*args, **kwargs)
  File "/var/www/brownpapersession/demo/brownpapersession/app/tasks.py", line 526, in send_email
    send_all()
  File "/var/www/brownpapersession/demo/env-brownpapersession/local/lib/python2.7/site-packages/mailer/engine.py", line 123, in send_all
    acquired, lock = acquire_lock()
  File "/var/www/brownpapersession/demo/env-brownpapersession/local/lib/python2.7/site-packages/mailer/engine.py", line 94, in acquire_lock
    lock.acquire(LOCK_WAIT_TIMEOUT)
  File "/var/www/brownpapersession/demo/env-brownpapersession/local/lib/python2.7/site-packages/lockfile/linklockfile.py", line 21, in acquire
    raise LockFailed("failed to create %s" % self.unique_name)
LockFailed: failed to create /var/www/brownpapersession/demo/brownpapersession/xxxxx-vps-76199700.114845734606605386126845

PR coming up

Protect against loop from EMAIL_BACKEND equal to MAILER_EMAIL_BACKEND?

Hi!

I had a situation where MAILER_EMAIL_BACKEND and EMAIL_BACKEND were both set to mailer.backend.DbBackend (with version 1.2.4). The symptom is that sending mails does not seem to work, until you notice that there is new rows in the database.

I was wondering if that's a scenario you consider worth protecting against. What do you think?

Best, Sebastian

Schedule emails

Is it possible to use django-mailer to schedule emails?
What I need is to be able to set a when_to_send field in the message model of django-mailer.
Maybe one could use the when_added field to achieve this?
Is anything like this planed?

My use case is that I want to send out an email when a new comment is created. But the email should be sent 10 minutes after the comment is created.

Can't send HTML emails

I've got some (simple) code that implements this I can push soon if people are interested.

Plain text body: <Can't decode>

When adding a message via the Django admin, not all of the form displays. It appears to stop at the 'Plain text body' field and just displays "<Can't decode>". No fields follow.

I tried setting it up via pip as well as the master branch on github. Running django 1.8.3 with python 3.4.3.

I haven't been able to look into this further yet. I'm hoping someone has already seen this issue before I start digging too far into django-mailer's guts.

header for identifying emails in transactional email services

Hi,

I use service to send transactional emails. Among other things, they provide a webhook where they post me messages about failed sends. When I receive such messages, it would be nice to be able to match messages up to the corresponding record in the mailer message log

i was thinking that one way to achieve this would be to give messages a uuid when saving them, and including this in a custom email header (don't want to use e.g. pk, since that leaks info)

is this something that would be interesting to this project? (would be happy to contribute implementation but only if it has a chance of getting accepted)

also open to other suggestions on how to do this

best,
david

Lockfile can't install.

I'm getting an import error on the pip install of lockfile

    return self.build_and_install(setup_script, setup_base)
  File "/webapps/dpms/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/webapps/dpms/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1115, in run_setup
    run_setup(setup_script, args)
  File "/webapps/dpms/lib/python2.7/site-packages/setuptools/sandbox.py", line 69, in run_setup
    lambda: execfile(
  File "/webapps/dpms/lib/python2.7/site-packages/setuptools/sandbox.py", line 120, in run
    return func()
  File "/webapps/dpms/lib/python2.7/site-packages/setuptools/sandbox.py", line 71, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 22, in <module>
    try:
  File "/tmp/easy_install-bIbCye/pbr-1.10.0/pbr/util.py", line 264, in cfg_to_args
  File "/tmp/easy_install-bIbCye/pbr-1.10.0/pbr/util.py", line 573, in wrap_commands
  File "/webapps/dpms/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named build
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

Anyway to not use the lockfile

Bulk create for performance

Hi,

I have a question related to the application's performance and, perhaps, an improvement.
In the send_messages method, in https://github.com/pinax/django-mailer/blob/master/mailer/backend.py#L8, why not using bulk_create https://docs.djangoproject.com/en/2.1/ref/models/querysets/#bulk-create, instead of saving one by one? This will significantly increase performance when sending a big amount of emails at once.

Tks and congrats for the great application :)
Sandro Rodrigues

Queue stalls when non-SMTP email backend raises error

I'm using django-mailer with a django-anymail backend (specifically, MAILER_EMAIL_BACKEND = "anymail.backends.postmark.PostmarkBackend").

Anymail is not based on smtplib, so it raises its own exceptions for rejected recipients or other errors. Because django-mailer is looking for specific SMTP exceptions, an Anymail exception ends up stalling the queue, rather than deferring the unsendable message. (The exception aborts the send_mail management command, leaving the unsendable message at the top of the prioritization list for the next send.)

What would be a reasonable way to solve this? (I maintain django-anymail, btw.)

  • I don't think it makes sense to add Anymail-specific exceptions to django-mailer. (Because that starts down the slippery slope to adding specific code for all other email backends.)
  • django-mailer could define and catch its own SendMailException (e.g.), in addition to the current SMTP exceptions. Then other packages that want to play nice with django-mailer could raise mailer.SendMailException when django-mailer is installed. (I'm not at all opposed to adding this to Anymail. But it would sort of start the opposite slippery slope, where email backends need to add specific code for any likely queueing wrappers.)
  • django-mailer's send_all could just catch Exception, rather than specific SMTP exceptions. I realize broad catch statements are generally a bad idea, but this seems like a case where it might be appropriate.

Thoughts? I'm happy to submit a PR if one of the django-mailer changes makes sense.

Multiple mail connection

Hi,

my django application use multiple account for send mail using connection parameter of send_mail function.

I see code of extension and use the default django mail settings.
But, in my config settings I have something like:

EMAIL_CONNECTIONS = {
    'default': {
        'from_email':'[email protected]',
        'host': 'smtp.server.com',
        'username': 'usr',
        'password': 'pwd',
        'use_tls': True,
    },
    'info': {
        'from_email':'[email protected]',
        'host': 'smtp.server.com',
        'username': 'usr',
        'password': 'pwd',
        'use_tls': True,
    },
}

How can I use django-mailer with multiple account ?

Salvo.

Searching by "to_address" or "to_addresses"

I tried adding a new search field, but I got the following error:

FieldError at /admin/mailer/messagelog/ Cannot resolve keyword 'to_addresses' into field. Choices are: id, log_message, message_data, message_id, priority, result, when_added, when_attempted

I think that searching by this field is not provided by default. What would be the most proper solution for this case?

sending email without delay?

Is it possible to use this package and send emails without the 1 minute delay imposed by the cronjob?

Most of the time the delay is fine but there are few circumstances like password reset and activation where I'd want the email to be sent out immediately. I'd still want the message log and the queue for failed connections. Is there a way to do this? I looked over the docs but couldn't find anything.

Thanks for your work on this package; it's really useful!

Error creating RPM

Traceback (most recent call last):
File "setup.py", line 7, in
long_description=open('docs/usage.txt').read(),
IOError: [Errno 2] No such file or directory: 'docs/usage.txt'
error: Bad exit status from /var/tmp/rpm-tmp.zLe4Dn (%build)

send_email not sending emails

HI, i am having some trouble sending queued emails with django-mailer=1.1 and django==1.7.x i call the send_email command and nothing happens. There are no errors and the email does not go.

Any ideas?

Message has no attribute when_attempted

Message has no attribute when_attempted, hence __str__ is always return <Message repr unavailable>:

    def __str__(self):
        try:
            email = self.email
            return "On {0}, \"{1}\" to {2}".format(self.when_attempted,
                                                   email.subject,
                                                   ", ".join(email.to))
        except Exception:
            return "<Message repr unavailable>"

As far as I'm concerned when_attempted should be replaced by when_added.

Problem with to_address field

Sincere apologies if I'm missing something here, but django_mailer is storing the to_addresses like this:

[u'[email protected]']

Which obviously means that emails are not being sent. I'm following the Django examples to call send_mail and send_html_mail:

send_html_mail(subject, message_text, message_html,
DEFAULT_FROM_EMAIL, [self.user.email])

I would really appreciate it if someone can put me right!

README is outdated

The README has a few instructions that are no longer supported in django. I'll shoot over a pull request with the changes in a few minutes.

Message priority

How can I set message priority? It seems like it's created by default with priority = 2 and there is no way to change it.

Files in wheel have wrong permissions, making it impossible to import the package

After installing the package using buildout, it is not possible to import anything from it unless running as root. This is caused by faulty permissions in the wheel file: as you can see below, only root has read permissions to the files. The correct mode should be -rw-rw-r--

-rw-r----- 1 root root 1.3K Jan 11 09:56 admin.py
-rw-r----- 1 root root 2.5K Jan 11 09:56 admin.pyc
-rw-r----- 1 root root  367 Jan 11 09:56 backend.py
-rw-r----- 1 root root 6.8K Jan 11 09:56 engine.py
-rw-r----- 1 root root 3.8K Jan 11 09:56 __init__.py
-rw-r----- 1 root root 4.2K Jan 11 09:56 __init__.pyc
drwxr-xr-x 3 root root 4.0K Jan 11 09:56 locale
drwxr-xr-x 3 root root 4.0K Jan 11 09:56 management
drwxr-xr-x 2 root root 4.0K Jan 11 09:56 migrations
-rw-r----- 1 root root 8.8K Jan 11 09:56 models.py
-rw-r----- 1 root root  13K Jan 11 09:56 models.pyc
drwxr-xr-x 2 root root 4.0K Jan 11 09:56 south_migrations
-rw-r----- 1 root root  29K Jan 11 09:56 tests.py

It seems like pip and easy_install fix the permissions, but buildout doesn't.

Lock Failed

Hey all,

Getting the following error running manage.py and no way of knowing how to debug this. Anyone has any advice?

acquiring lock...
LockFailed:

immediately sending email

Is there a way to circumvent having to run an external command to send emails every 1 minute using cron? I want to be able to send an email immediately.

Is there an alternative to this?

can't pickle lock objects

Hi,

As of 93c378e, manage.py send_mail has started throwing an exception about pickling. It seems that https://github.com/pinax/django-mailer/blob/master/mailer/engine.py#L131 tries to pickle an email with a connection attached, and when using the django smtp email backend, that connection does indeed have a _lock attribute.

Traceback (most recent call last):
  File "/srv/project/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/srv/environments/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/srv/environments/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/environments/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/srv/environments/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/srv/environments/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 533, in handle
    return self.handle_noargs(**options)
  File "/srv/environments/project/local/lib/python2.7/site-packages/mailer/management/commands/send_mail.py", line 30, in handle_noargs
    send_all()
  File "/srv/environments/project/local/lib/python2.7/site-packages/mailer/engine.py", line 131, in send_all
    message.email = email  # For the sake of MessageLog
  File "/srv/environments/project/local/lib/python2.7/site-packages/mailer/models.py", line 134, in _set_email
    self.message_data = email_to_db(val)
  File "/srv/environments/project/local/lib/python2.7/site-packages/mailer/models.py", line 81, in email_to_db
    return base64_encode(pickle.dumps(email))
  File "/usr/lib/python2.7/pickle.py", line 1374, in dumps
    Pickler(file, protocol).dump(obj)
  File "/usr/lib/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
    save(v)
  File "/usr/lib/python2.7/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/srv/environments/project/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle lock objects

ask github to make this repo the main repo

It should be possible to get github (through a support request) to make this repo the main repo. This would change the display from this:

pinax/django-mailer
forked from jtauber/django-mailer 

to just this:

pinax/django-mailer

This would be more clear to everybody using and contributing to this project. Thanks!

TypeError: sequence item 0: expected str instance, tuple found

I can see some e-mails are sent, however, this error is persistent after running manage.py send_email.

class EmailThread(threading.Thread):
    def __init__(self, subject, context, recipient, template):
        self.subject = subject
        self.recipient = recipient
        self.message = get_template(template).render(context)
        threading.Thread.__init__(self)

    def run(self):
        msg = EmailMessage(
            subject=self.subject + " (DEBUG)" if settings.DEBUG else self.subject,
            from_email=settings.DEFAULT_DO_NOT_REPLY,
            to=self.recipient,
            body=self.message
        )
        msg.content_subtype = "html"

        try:
            msg.send(fail_silently=False)
            log.info("E-mail triggered. Subject: '%s', to: %s" % (self.subject, self.recipient))
        except Exception as e:
            log.exception(e)


def notify_admin_blocked_account(user):
    """
    Sends sends an email when the account is blocked
    :return:
    """
    email = EmailThread(
        subject='{}, your account has been blocked'.format(user),
        context={
            'user': user,
            'login_attempts': settings.MAX_STAFF_PWD_ATTEMPTS,
        },
        recipient=[user.email,],
        template='mail/notify_admin_blocked_account.html'
    )
    email.start()
python manage.py send_mail
------------------------------------------------------------------------
acquiring lock...
acquired.
releasing lock...
released.
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/documents/envs/atomenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/documents/envs/atomenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/documents/envs/atomenv/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/documents/envs/atomenv/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/documents/envs/atomenv/lib/python3.5/site-packages/mailer/management/commands/send_mail.py", line 26, in handle
    send_all()
  File "/documents/envs/atomenv/lib/python3.5/site-packages/mailer/engine.py", line 133, in send_all
    u", ".join(message.to_addresses).encode("utf-8"))
TypeError: sequence item 0: expected str instance, tuple found

Django 1.11.3
Python 3.5.2

send_mail error

when I run the send_mail management command I receive this error

File "........./.././lib/mailer/lockfile.py", line 60, in
from six.moves.urllib.parse import quote
ImportError: No module named urllib.parse

I get this error both on my local dev machine and on the production server.

I am running python 2.6 on both.

Anyone had this problem before?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.