Outgoing Email Settings as part of Frappe, fix in copy doc

This commit is contained in:
Anand Doshi 2014-03-03 20:30:50 +05:30
parent 2946cbd1f5
commit ebd825e0c7
11 changed files with 142 additions and 23 deletions

View file

@ -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':

View file

@ -95,7 +95,7 @@ data = [
"items": [
{
"type": "doctype",
"name": "Email Settings",
"name": "Outgoing Email Settings",
"description": _("Set outgoing mail server.")
},
]

View file

@ -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 += "<p>Please see attachment for document details.</p>"

View file

@ -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

View file

@ -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": "<a href=\"https://en.wikipedia.org/wiki/Transport_Layer_Security\" target=\"_blank\">[?]</a>",
"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"
}
]

View file

@ -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]) {

View file

@ -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() {

View file

@ -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)

View file

@ -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

View file

@ -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