diff --git a/frappe/boot.py b/frappe/boot.py index 2b28921a47..8588c7b149 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -28,7 +28,7 @@ def get_bootinfo(): bootinfo['control_panel'] = frappe._dict(cp.copy()) bootinfo['sysdefaults'] = frappe.defaults.get_defaults() bootinfo['server_date'] = frappe.utils.nowdate() - bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Email Settings", + bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Outgoing Email Settings", None, "send_print_in_body_and_attachment") if frappe.session['user'] != 'Guest': diff --git a/frappe/config/setup.py b/frappe/config/setup.py index 3e7f881962..de810f221b 100644 --- a/frappe/config/setup.py +++ b/frappe/config/setup.py @@ -95,7 +95,7 @@ data = [ "items": [ { "type": "doctype", - "name": "Email Settings", + "name": "Outgoing Email Settings", "description": _("Set outgoing mail server.") }, ] diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index 587c5a8901..f2393048c8 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -118,7 +118,7 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s footer = set_portal_link(sent_via, d) - send_print_in_body = frappe.db.get_value("Email Settings", None, "send_print_in_body_and_attachment") + send_print_in_body = frappe.db.get_value("Outgoing Email Settings", None, "send_print_in_body_and_attachment") if not send_print_in_body: d.content += "

Please see attachment for document details.

" diff --git a/frappe/core/doctype/outgoing_email_settings/__init__.py b/frappe/core/doctype/outgoing_email_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.py b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.py new file mode 100644 index 0000000000..9034fbe70d --- /dev/null +++ b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + self.doc.encode() + if self.doc.server: + from frappe.utils import cint + from frappe.utils.email_lib.smtp import SMTPServer + smtpserver = SMTPServer(login = self.doc.mail_login, + password = self.doc.mail_password, + server = self.doc.server, + port = cint(self.doc.mail_port), + use_ssl = self.doc.use_ssl + ) + + # exceptions are handled in session connect + sess = smtpserver.sess \ No newline at end of file diff --git a/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.txt b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.txt new file mode 100644 index 0000000000..c50616c786 --- /dev/null +++ b/frappe/core/doctype/outgoing_email_settings/outgoing_email_settings.txt @@ -0,0 +1,107 @@ +[ + { + "creation": "2014-03-03 19:48:01", + "docstatus": 0, + "modified": "2014-03-03 20:20:09", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "allow_copy": 1, + "description": "Email Settings for Outgoing and Incoming Emails.", + "doctype": "DocType", + "icon": "icon-cog", + "in_create": 1, + "issingle": 1, + "module": "Core", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Outgoing Email Settings", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Outgoing Email Settings", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "read": 1, + "role": "System Manager", + "write": 1 + }, + { + "doctype": "DocType", + "name": "Outgoing Email Settings" + }, + { + "description": "SMTP Server (e.g. smtp.gmail.com)", + "doctype": "DocField", + "fieldname": "mail_server", + "fieldtype": "Data", + "label": "Outgoing Mail Server" + }, + { + "description": "[?]", + "doctype": "DocField", + "fieldname": "use_ssl", + "fieldtype": "Check", + "label": "Use TLS" + }, + { + "description": "If non standard port (e.g. 587)", + "doctype": "DocField", + "fieldname": "mail_port", + "fieldtype": "Int", + "label": "Port" + }, + { + "doctype": "DocField", + "fieldname": "cb0", + "fieldtype": "Column Break" + }, + { + "description": "Set Login and Password if authentication is required.", + "doctype": "DocField", + "fieldname": "mail_login", + "fieldtype": "Data", + "label": "Login Id" + }, + { + "description": "Check this if you want to send emails as this id only (in case of restriction by your email provider).", + "doctype": "DocField", + "fieldname": "always_use_login_id_as_sender", + "fieldtype": "Check", + "label": "Always use above Login Id as sender" + }, + { + "doctype": "DocField", + "fieldname": "mail_password", + "fieldtype": "Password", + "label": "Mail Password" + }, + { + "description": "System generated mails will be sent from this email id.", + "doctype": "DocField", + "fieldname": "auto_email_id", + "fieldtype": "Data", + "label": "Auto Email Id" + }, + { + "default": "1", + "description": "If checked, an email with an attached HTML format will be added to part of the EMail body as well as attachment. To only send as attachment, uncheck this.", + "doctype": "DocField", + "fieldname": "send_print_in_body_and_attachment", + "fieldtype": "Check", + "label": "Send Print in Body and Attachment" + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/frappe/public/js/frappe/model/create_new.js b/frappe/public/js/frappe/model/create_new.js index 823126a689..6637cf26fb 100644 --- a/frappe/public/js/frappe/model/create_new.js +++ b/frappe/public/js/frappe/model/create_new.js @@ -123,7 +123,7 @@ $.extend(frappe.model, { }, copy_doc: function(dt, dn, from_amend) { - var no_copy_list = ['name','amended_from','amendment_date','cancel_reason','idx']; + var no_copy_list = ['name','amended_from','amendment_date','cancel_reason']; var newdoc = frappe.model.get_new_doc(dt); for(var key in locals[dt][dn]) { diff --git a/frappe/public/js/frappe/model/model.js b/frappe/public/js/frappe/model/model.js index b73f1611ac..4c81003f42 100644 --- a/frappe/public/js/frappe/model/model.js +++ b/frappe/public/js/frappe/model/model.js @@ -363,20 +363,6 @@ $.extend(frappe.model, { return no_copy_list; }, - copy_doc: function(dt, dn, from_amend) { - var no_copy_list = frappe.model.get_no_copy_list(dt); - var newdoc = frappe.model.get_new_doc(dt); - - for(var key in locals[dt][dn]) { - // dont copy name and blank fields - if(key.substr(0,2)!='__' - && !in_list(no_copy_list, key)) { - newdoc[key] = locals[dt][dn][key]; - } - } - return newdoc; - }, - // args: source (doclist), target (doctype), table_map, field_map, callback map: function(args) { frappe.model.with_doctype(args.target, function() { diff --git a/frappe/utils/email_lib/bulk.py b/frappe/utils/email_lib/bulk.py index 2b1eaa06eb..110e03dcab 100644 --- a/frappe/utils/email_lib/bulk.py +++ b/frappe/utils/email_lib/bulk.py @@ -54,7 +54,7 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email', if not recipients: recipients = [] if not sender or sender == "Administrator": - sender = frappe.db.get_value('Email Settings', None, 'auto_email_id') + sender = frappe.db.get_value('Outgoing Email Settings', None, 'auto_email_id') check_bulk_limit(len(recipients)) formatted = get_formatted_html(subject, message) diff --git a/frappe/utils/email_lib/email_body.py b/frappe/utils/email_lib/email_body.py index 6f374f82ec..4c732ad461 100644 --- a/frappe/utils/email_lib/email_body.py +++ b/frappe/utils/email_lib/email_body.py @@ -159,10 +159,10 @@ class EMail: return email if not self.sender: - self.sender = frappe.db.get_value('Email Settings', None, + self.sender = frappe.db.get_value('Outgoing Email Settings', None, 'auto_email_id') or frappe.conf.get('auto_email_id') or None if not self.sender: - msgprint(_("Please specify 'Auto Email Id' in Setup > Email Settings")) + msgprint(_("Please specify 'Auto Email Id' in Setup > Outgoing Email Settings")) if not "expires_on" in frappe.conf: msgprint(_("Alternatively, you can also specify 'auto_email_id' in site_config.json")) raise frappe.ValidationError diff --git a/frappe/utils/email_lib/smtp.py b/frappe/utils/email_lib/smtp.py index 42a4bdcc23..5312b8d79c 100644 --- a/frappe/utils/email_lib/smtp.py +++ b/frappe/utils/email_lib/smtp.py @@ -38,7 +38,7 @@ class SMTPServer: def __init__(self, login=None, password=None, server=None, port=None, use_ssl=None): # get defaults from control panel try: - es = frappe.doc('Email Settings','Email Settings') + es = frappe.doc('Outgoing Email Settings', 'Outgoing Email Settings') except frappe.DoesNotExistError: es = None @@ -50,7 +50,7 @@ class SMTPServer: self.login = login self.password = password elif es and es.outgoing_mail_server: - self.server = es.outgoing_mail_server + self.server = es.mail_server self.port = es.mail_port self.use_ssl = cint(es.use_ssl) self.login = es.mail_login