def send_email(to_address, subject, content, html_content, bcc_address=None, attachment=None, attachment2=None, attachment3=None): new_message = MailerMessage() new_message.subject = subject new_message.to_address = to_address if bcc_address: new_message.bcc_address = bcc_address new_message.from_address = settings.DEFAULT_FROM_EMAIL new_message.content = content new_message.html_content = html_content new_message.cc_address = settings.DEFAULT_CC_EMAIL if attachment: new_message.add_attachment(attachment) if attachment2: new_message.add_attachment(attachment2) if attachment3: new_message.add_attachment(attachment3) new_message.app = "our app name" new_message.save()
def create_mail_message(request): new_message = MailerMessage() new_message.subject = "My Subject" new_message.to_address = "*****@*****.**" new_message.cc_address = "*****@*****.**" new_message.bcc_address = "*****@*****.**" new_message.from_address = "*****@*****.**" new_message.content = "Mail content" new_message.html_content = "<h1>Mail Content</h1>" new_message.app = "Name of your App that is sending the email." new_message.save() return render(request, 'index.html')
def _setup_email(self): msg = MailerMessage() msg.from_address = self.from_address msg.to_address = self._get_formatted_recipients(self.to) if self.cc: msg.cc_address = self._get_formatted_recipients(self.cc) full_bcc = self._get_bcc_with_debugging_copy() if full_bcc: msg.bcc_address = self._get_formatted_recipients(full_bcc) msg.subject = self.get_rendered_subject() msg.html_content = self.get_rendered_html_body() msg.content = self.get_plain_text_body() msg.app = self.mail.text_identifier return msg