SMTPConnection with Return-Path

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from django.core.mail import SMTPConnection

class CustomSMTPConnection(SMTPConnection):
    """Simple override of SMTPConnection to allow a Return-Path to be specified"""
    def __init__(self, return_path=None, **kwargs):
        self.return_path = return_path
        super(CustomSMTPConnection, self).__init__(**kwargs)
    
    def _send(self, email_message):
        """A helper method that does the actual sending."""
        if not email_message.to:
            return False
        try:
            return_path = self.return_path or email_message.from_email
            self.connection.sendmail(return_path,
                    email_message.recipients(),
                    email_message.message().as_string())
        except:
            if not self.fail_silently:
                raise
            return False
        return True

More like this

  1. Function to create resized versions of an image from a URL and saving it to a local path by obeattie 4 years, 11 months ago
  2. email_links by sansmojo 4 years, 8 months ago
  3. EasyFeed class by limodou 4 years, 11 months ago
  4. IfValueTag by adurdin 4 years, 10 months ago
  5. Email Munger by cootetom 3 years ago

Comments

CardenasCecelia (on December 26, 2011):

I think that to get the loan from banks you should have a great reason. But, once I have got a commercial loan, just because I wanted to buy a bike.

#

(Forgotten your password?)