A package for sending email from your Pyramid application

Related tags

Email pyramid_mailer
Overview

pyramid_mailer

https://travis-ci.org/Pylons/pyramid_mailer.png?branch=master Documentation Status

pyramid_mailer is a package for sending email from your Pyramid application. It is compatible with Python 2.7, 3.4, 3.5, 3.6, and 3.7 as well as PyPy.

This package includes:

  1. Wrapping the low-level Python email library with an easy-to-use API, which includes attachments and mulipart content.
  2. Sending emails immediately or add to a maildir queue.
  3. Managing email sends inside a transaction, to prevent emails being sent if your code raises an exception.
  4. Features to help with unit testing.

pyramid_mailer uses the repoze.sendmail library for managing email sending and transacton management, and borrows code (with permission) from Zed Shaw's lamson for wrapping email messages. See the LICENSE.txt file for more information.

Links

Comments
  • cannot send email with only bcc

    cannot send email with only bcc

    message = Message(subject='test', body='this is a test', bcc=['[email protected]'])
    mailer.send(message)
    transaction.commit()
    
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "test.py", line 83, in <module>
        main(sys.argv)
      File "test.py", line 79, in main
        mailer.send(message)
      File "lib/python2.7/site-packages/pyramid_mailer/mailer.py", line 178, in send
        return self.direct_delivery.send(*self._message_args(message))
      File "lib/python2.7/site-packages/pyramid_mailer/mailer.py", line 222, in _message_args
        message.to_message())
      File "lib/python2.7/site-packages/pyramid_mailer/message.py", line 82, in to_message
        self.validate()
      File "lib/python2.7/site-packages/pyramid_mailer/message.py", line 132, in validate
        raise InvalidMessage, "No recipients have been added"
    pyramid_mailer.exceptions.InvalidMessage: No recipients have been added
    
    opened by mmerickel 16
  • bcc field visibility with `pyramid_mailer debug`

    bcc field visibility with `pyramid_mailer debug`

    We are using pyramid mailer debug for manual QA of features. It would be nice to have a configuration option to include the bcc field (in any format) as part of the .msg files for ease of testing. I can provide the PR if we agree this would be useful.

    opened by RaHus 14
  • UnicodeDecodeError, pyramid_mailer 0.9, repoze.sendmail 3.2

    UnicodeDecodeError, pyramid_mailer 0.9, repoze.sendmail 3.2

    Hi I am trying to attach a pdf and when I do some sort of encoding issue pops up. I can send a csv file no problem it's only when I add the pdf (or another binary file like a gpg key) that this encoding issue comes up.

    I saw issue 17 which seems similar to mine but that is fixed in the versions I am using right?

    This is the code I am using, I've tried setting the disposition explicitly to 'attachment' as well as using the full file location for the file name.

       csv_attachment = Attachment("%s.csv" % report.name, "text/csv", open(csv_loc, "rb"), 'attachment')
       pdf_attachment = Attachment("%s.pdf" % report.name, "application/pdf", open(pdf_loc, "rb"), 'attachment')
    
        body = render('mail/report.mak', {'user':user, 'report':report}, request)
        message = Message(subject='Famoso Reporting - %s' % report.name,
                    sender='Famoso Admin <[email protected]>',
                    recipients=[user.email],
                    body=body,
                    attachments=[csv_attachment,pdf_attachment])
        mailer.send(message)
    

    Here is the traceback of the error:

    Traceback (most recent call last): File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/waitress-0.8.1-py2.6.egg/waitress/channel.py", line 329, in service task.service() File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/waitress-0.8.1-py2.6.egg/waitress/task.py", line 173, in service self.execute() File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/waitress-0.8.1-py2.6.egg/waitress/task.py", line 380, in execute app_iter = self.channel.server.application(env, start_response) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/pyramid/router.py", line 187, in call response = self.handle_request(request) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/pyramid/tweens.py", line 20, in excview_tween response = handler(request) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/pyramid_tm-0.4-py2.6.egg/pyramid_tm/init.py", line 102, in tm_tween return response File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_manager.py", line 96, in exit self.commit() File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_manager.py", line 89, in commit return self.get().commit() File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_transaction.py", line 342, in commit reraise(t, v, tb) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_transaction.py", line 333, in commit self._commitResources() File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_transaction.py", line 473, in _commitResources reraise(t, v, tb) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/transaction/_transaction.py", line 455, in _commitResources rm.tpc_finish(self) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/repoze/sendmail/delivery.py", line 70, in tpc_finish self.callable(*self.args) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/repoze/sendmail/mailer.py", line 53, in send message = encode_message(message) File "/Users/rottaway/PyEnvs/famoso_reports/lib/python2.6/site-packages/repoze/sendmail/encoding.py", line 101, in encode_message return message.as_string().encode('ascii') UnicodeDecodeError: 'ascii' codec can't decode byte 0xb5 in position 1476: ordinal not in range(128)

    opened by robottaway 12
  • Upgrade Python support to include 3.8 and 3.9 (Removing 2.7)

    Upgrade Python support to include 3.8 and 3.9 (Removing 2.7)

    This also:

    • Drops Python 2.7 support
    • Removes Python 2.7 compatibility switches
    • Combines the coverage steps into one
    • Updates the docs etc, to run in Python 3.9
    • No longer permits failures in Python 3.8 in Travis
    opened by jon-betts 7
  • Bug python 3.4.X

    Bug python 3.4.X

    Hi, I tried send an email with pyramid_mailer using mailer.send_immediately(message_instance) I given this: *** TypeError: unorderable types: str() > int()

    https://www.dropbox.com/s/rvxggi0wqdtdarl/Captura%20de%20tela%202015-05-21%2017.19.38.png?dl=0

    opened by marioidival 7
  • Set a default message sender if no sender set in DebugMailer

    Set a default message sender if no sender set in DebugMailer

    Use-case: I construct Messages in my code without a sender, because I want to use the default_sender as the sender. Works as a charm with Mailer.

    However, when I use DebugMailer with these Messages, I get a message a validation error, because the sender is not set. The Mailer class takes care of setting the sender if default sender is set, but the DebugMailer does not do that. This patch then sets a dummy sender, if no sender is set in Message, to allow using DebugMailer with sender-less Messages.

    opened by zupo 6
  • Drop Python 2.6 support

    Drop Python 2.6 support

    Yesterday marks 3 years since the last release of Python 2.6! 🎉

    To celebrate, I'm attempting to drop support for it from 156 prominent Python packages (one for every week it's past end-of-life)--including this one!

    I've tried my best to remove as much 2.6-specific cruft as I can, but at the very least, this PR will remove the 'Programming Language :: Python :: 2.6' trove classifier from this projects setup.py.

    opened by di 5
  • UnicodeEncodeError with multipart unicode messages

    UnicodeEncodeError with multipart unicode messages

    This fails:

    def test_multipart_encoding(self):
        from repoze.sendmail import encoding
        from pyramid_mailer.message import Message
    
        msg = Message(subject="testing",
                      sender="[email protected]",
                      body=u"tästing",
                      html=u"<b>tästing</b>",
                      recipients=["[email protected]"])
        result = encoding.encode_message(msg.to_message())
    

    It worked fine with repoze.sendmail 2.3 and the pyramid-mailer 0.6.

    Either I use it wrong, or there is a problem in pyramid-mailer or repoze.sendmail.

    opened by fschulze 5
  • Fix the email line ending as required by RFC2822 on Python 3

    Fix the email line ending as required by RFC2822 on Python 3

    Fix the email line ending as required by RFC2822 on Python 3 by using the Python 3.2 compatibility policy with custom line ending. This is indeed a bug in pyramid_mailer; the email.policy package contains different serialization formats - the one used by default uses \n for line endings and is thus not suitable for sending emails; for that a serializer policy that uses \r\n is needed.

    Now one question is that if a message is queued in a file then the line endings can be changed again...

    opened by ztane 4
  • QueuedMailDelivery nor DirectMailDelivery do not accept transaction_manager keyword

    QueuedMailDelivery nor DirectMailDelivery do not accept transaction_manager keyword

    As per title currently including (via config.include('pyramid_mailer') pyramid_mailer breaks my application with:

    File "/home/ergo/Private/workspace/pyramid_mailer/pyramid_mailer/init.py", line 11, in mailer_factory_from_settings return Mailer.from_settings(settings, prefix) File "/home/ergo/Private/workspace/pyramid_mailer/pyramid_mailer/mailer.py", line 281, in from_settings return cls(username=username, password=password, **kwargs) File "/home/ergo/Private/workspace/pyramid_mailer/pyramid_mailer/mailer.py", line 226, in init self.smtp_mailer, transaction_manager=transaction_manager) TypeError: init() got an unexpected keyword argument 'transaction_manager'

    I've made a PR that resolves this, the test suite passes and I was able to successfully send email via: mailer.send(message) and mailer.send_immediatelly(message)

    opened by ergo 4
  • pyramid_mailer.testing doesn't add mailer to the request object

    pyramid_mailer.testing doesn't add mailer to the request object

    As stated in the title, using pyramid.includes = pyramid_mailer.testing won't add the mailer attribute to a request object, while pyramid.includes = pyramid_mailer does add the attribute.

    This almost seems like an oversight, except that that testing.py was last touched almost six years ago (and I can't find a history of anyone complaining about this).

    What was the reasoning behind this?

    opened by dfee 4
  • pyramid mailer incorrectly encodes from-header if international characters exist

    pyramid mailer incorrectly encodes from-header if international characters exist

    Python 3.10, if relevant,

    >>> m = pyramid_mailer.message.Message(sender='ÄÖ <foo@bar>', recipients=['baz@quux'], body='foo')
    >>> print(m.to_message().as_string())
    Content-Type: text/plain; charset="us-ascii"
    MIME-Version: 1.0
    Content-Transfer-Encoding: quoted-printable
    From: =?utf-8?b?w4TDliA8Zm9vQGJhcj4=?=
    To: baz@quux
    Content-Disposition: inline
    
    foo
    

    The header is incorrectly quoted, the quoting must not affect the actual header. For example Amazon SES is unable to handle this. Not sure if anything else would either. I guess the fix would be to use the email.message.EmailMessage from Python 3.6+.

    opened by ztane 0
  • remove pyramid dependency

    remove pyramid dependency

    Sometimes, e.g. in a containerised batch emailer, it is desirable to use pyramid_mailer without pulling in pyramid.

    The dependency exists only so that a few dozen lines of list manipulation functions can be used.

    This commit copies this code into pyramid_mailer and slightly simplifies it.

    opened by tomscytale 2
  • Time for a new release?

    Time for a new release?

    master has seen quite a bit of activity since the last release: https://github.com/Pylons/pyramid_mailer/compare/0.15.1...master

    Might it be a good idea to cut a new release? :thinking:

    opened by gforcada 1
  • added support for a different sender in the SMTP envelope than the sender

    added support for a different sender in the SMTP envelope than the sender

    It's good practice on automatic generated mails to haven automatic error handling. To be able to have errors while delivering the Mail automatically handled is to have a e-mail address that processes bounces. The sender of a mail should be an address where a human reads the Mails.

    So we need two different senders on one mail. One that is only used while delivering the mail and on the recipient sees a sender of this mail.

    Most do this by using the automatic bounce processing address as envelop from and the human address in the From: header. So the recipient of the Mails only see the Human address but the delivery system sees the automatic address as sender.

    The Errors-To: header isn't really supported and the automatic address as sender and the human address as Reply-To: do work most of the times but exposes the automatic address as sender is usualy a unreadable address.

    opened by Estartu 2
  • Add an heartbeat functionnality

    Add an heartbeat functionnality

    Is there a way to get if the pyramid_mailer is correctly configured (connection with the SMTP server is possible with given credentials).

    I know I could do that by sending an email to a wrong mailbox, but I would like to avoid doing that if possible. Is it possible to add a ping() method to the mailer that would answer true or false depending of is the connection was successful or not?

    opened by Natim 1
Owner
Pylons Project
The Pylons Project is composed of a disparate group of project leaders with experience going back to the very start of Python web frameworks.
Pylons Project
A Django email backend that uses a celery task for sending the email.

django-celery-email - A Celery-backed Django Email Backend A Django email backend that uses a Celery queue for out-of-band sending of the messages. Wa

Paul McLanahan 430 Dec 16, 2022
GMailBomber is a form of Internet abuse which is perpetrated through the sending of massive volumes of email to a specific email address with the goal of overflowing the mailbox and overwhelming the mail server hosting the address, making it into some form of denial of service attack.

GMailBomber is a form of Internet abuse which is perpetrated through the sending of massive volumes of email to a specific email address with the goal of overflowing the mailbox and overwhelming the mail server hosting the address, making it into some form of denial of service attack.

Muneeb 5 Nov 13, 2022
Bulk Email and certificate sending application

demir.ai E-mail services This application allows you to send automatic mass mail and automatic mass certificates to the people in your mailing list, m

Ahmet Furkan DEMIR 16 Nov 1, 2022
Automated email sending application.

autoMail Automated email sending application. This application sends email to a user when added to database. Email message contains the temperature of

Bhat Owais 1 Feb 12, 2022
Fast Anonymous Email Sending Tool

Email-Fake Fast Anonymous Email Sending Tool ?? Github Statistics : Termux For Install: pkg install python pkg install python2 git clone https://githu

Aryan 7 May 28, 2022
Command line interface for sending email using SMTP (ships with Gmail configuration).

mailsend Description Lightweight command line interface for sending email using SMTP. Default configuration is set for Gmail (smtp.gmail.com at port 5

Keith Mathe 1 Mar 22, 2022
An email sending system with random confirmation code.

email_sending An email sending system with random confirmation code. Description Confirmation emails are sent based on the list of email addresses. Ea

Larissa Queiroz 2 Mar 22, 2022
Mailer is python3 script use for sending spear-phishing to target email...It was created by Spider Anongreyhat

Mailer Mailer is a python3 script. It's used for sending spear-phishing to target email...It was created by Spider Anongreyhat Screenshots Installatio

Spider Anongreyhat 31 Dec 5, 2022
A Django app that allows you to send email asynchronously in Django. Supports HTML email, database backed templates and logging.

Django Post Office Django Post Office is a simple app to send and manage your emails in Django. Some awesome features are: Allows you to send email as

User Inspired 856 Dec 25, 2022
A Django email backend for Amazon's Simple Email Service

Django-SES Info: A Django email backend for Amazon's Simple Email Service Author: Harry Marr (http://github.com/hmarr, http://twitter.com/harrymarr) C

null 882 Dec 29, 2022
Djrill is an email backend and new message class for Django users that want to take advantage of the Mandrill transactional email service from MailChimp.

Djrill: Mandrill Transactional Email for Django Djrill integrates the Mandrill transactional email service into Django. PROJECT STATUS: INACTIVE As of

Brack3t 327 Oct 1, 2022
Esio_dev 3 Oct 15, 2021
faceFarm is an active yahoo email detection script that functions to take over the facebook account using email.

faceFarm – The simple Email Detector. Email Valid Detector for Facebook (Yahoo) faceFarm is an active yahoo email detection script that functions to t

Fadjrir Herlambang 2 Jan 18, 2022
This Python program generates a random email address and password from a 2 big lists and checks the generated email.

This Python program generates a random email address and password from a 2 big lists and checks the generated email.

Killin 13 Dec 4, 2022
Email-osint - Email OSINT tool written in python3

Email-osint - Email OSINT tool written in python3

Surtains 7 Nov 28, 2022
A django package which act as a gateway to send and receive email with amazon SES.

django-email-gateway: Introduction: A Simple Django app to easily send emails, receive inbound emails from users with different email vendors like AWS

MicroPyramid 28 Nov 9, 2022
Will iterate through a list of emails on an attached csv file and email all of them a message of your choice

Email_Bot Will iterate through a list of emails on an attached csv file and email all of them a message of your choice. Before using, make sure you al

J. Brandon Walker 1 Nov 30, 2021
Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)

Fastapi-mail The fastapi-mail simple lightweight mail system, sending emails and attachments(individual && bulk) ?? Installation $ pip install fastap

Sabuhi 399 Dec 29, 2022
Python library for sending emails.

Mail.py Python library for sending emails. Installation git clone https://github.com/SunPodder/Mail.py cd Mail.py python setup.py install Usage Imp

Sun 3 Oct 15, 2021