From 3a839cb705fc3d647d14f2ae8df23ef7dd6215ae Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 17 Nov 2015 11:42:53 +0530 Subject: [PATCH] [minor] [fix] default sender in email account --- frappe/email/bulk.py | 2 +- frappe/email/email_body.py | 3 +-- frappe/email/smtp.py | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/email/bulk.py b/frappe/email/bulk.py index e122e7e90a..35892cf903 100644 --- a/frappe/email/bulk.py +++ b/frappe/email/bulk.py @@ -48,7 +48,7 @@ def send(recipients=None, sender=None, subject=None, message=None, reference_doc if not sender or sender == "Administrator": email_account = get_outgoing_email_account() - sender = email_account.get("sender") or email_account.email_id + sender = email_account.default_sender check_bulk_limit(recipients) diff --git a/frappe/email/email_body.py b/frappe/email/email_body.py index 41ce986064..66522d1d7f 100644 --- a/frappe/email/email_body.py +++ b/frappe/email/email_body.py @@ -161,8 +161,7 @@ class EMail: self.add_attachment(name, get_pdf(html, options), 'application/octet-stream') def get_default_sender(self): - email_account = get_outgoing_email_account() - return email.utils.formataddr((email_account.name, email_account.get("sender") or email_account.get("email_id"))) + return get_outgoing_email_account().default_sender def validate(self): """validate the email ids""" diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index 189369a699..35cf0c4c83 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe import smtplib +import email.utils import _socket from frappe.utils import cint from frappe import _ @@ -58,6 +59,9 @@ def get_outgoing_email_account(raise_exception_not_set=True, append_to=None): frappe.throw(_("Please setup default Email Account from Setup > Email > Email Account"), frappe.OutgoingEmailError) + email_account.default_sender = email.utils.formataddr((email_account.name, + email_account.get("sender") or email_account.get("email_id"))) + frappe.local.outgoing_email_account[append_to or "default"] = email_account return frappe.local.outgoing_email_account[append_to or "default"]