Exemple #1
0
def send_html_mail(subject, message, message_html, from_email, recipient_list,
				   priority="normal", fail_silently=False, auth_user=None,
				   auth_password=None, bcc=None, reply_to=None, attachment_path=None):
	"""
	Function to queue HTML e-mails
	"""
	if reply_to is None:
		reply_to = settings.REPLY_TO

	priority = PRIORITIES[priority]

	# need to do this in case subject used lazy version of ugettext
	subject = force_unicode(subject)
	message = force_unicode(message)

	email = EmailMultiAlternatives(
		subject,
		message,
		from_email,
		recipient_list,
		bcc=bcc,
		headers={'Reply-To': reply_to})
	email.attach_alternative(message_html, "text/html")
	if attachment_path is not None:
		# email.attach(attachment_filename, attachment_content)
		email.attach_file(attachment_path)

	queue_email_message(email, priority=priority)
	return 1
 def test_send_all_non_empty_queue(self):
     msg = mail.EmailMessage('subject', 'body', '*****@*****.**',
                             ['*****@*****.**'])
     queue_email_message(msg)
     engine.send_all()
     self.output.seek(0)
     self.assertEqual(self.output.readlines()[-1].strip()[-8:], 'seconds.')
Exemple #3
0
	def send_email():
		email = EmailMultiAlternatives(
			subject,
			message,
			from_email,
			recipient_list,
			bcc=bcc,
			headers={'Reply-To': (reply_to if reply_to else settings.REPLY_TO)})
		queue_email_message(email, priority=priority)
Exemple #4
0
 def queue_message(self, subject='test', message='a test message',
                   from_email='sender@djangomailer',
                   recipient_list=['recipient@djangomailer'],
                   priority=None):
     email_message = mail.EmailMessage(subject, message, from_email,
                                       recipient_list)
     return queue_email_message(email_message, priority=priority)
Exemple #5
0
    def send_messages(self, email_messages):
        """
        Add new messages to the email queue.

        The ``email_messages`` argument should be one or more instances
        of Django's core mail ``EmailMessage`` class.

        The messages can be assigned a priority in the queue by including
        an 'X-Mail-Queue-Priority' header set to one of the option strings
        in models.PRIORITIES.

        """
        if not email_messages:
            return

        from django_yubin import queue_email_message

        num_sent = 0
        for email_message in email_messages:
            queue_email_message(email_message)
            num_sent += 1
        return num_sent
    def send_messages(self, email_messages):
        """
        Add new messages to the email queue.

        The ``email_messages`` argument should be one or more instances
        of Django's core mail ``EmailMessage`` class.

        The messages can be assigned a priority in the queue by including
        an 'X-Mail-Queue-Priority' header set to one of the option strings
        in models.PRIORITIES.

        """
        if not email_messages:
            return

        from django_yubin import queue_email_message

        num_sent = 0
        for email_message in email_messages:
            if queue_email_message(email_message):
                num_sent += 1
        return num_sent
Exemple #7
0
 def send_message(self, msg):
     if constants.EMAIL_BACKEND_SUPPORT:
         msg.send()
     else:
         queue_email_message(msg)
Exemple #8
0
 def send_message(self, msg):
     if constants.EMAIL_BACKEND_SUPPORT:
         msg.send()
     else:
         queue_email_message(msg)