소스 검색

[email] [communication] fixes - use profile's email address to send email in Communication Composer

version-14
Anand Doshi 12 년 전
부모
커밋
2bd6eecaa6
4개의 변경된 파일60개의 추가작업 그리고 50개의 파일을 삭제
  1. +1
    -4
      core/doctype/communication/communication.py
  2. +55
    -43
      public/js/wn/views/communication.js
  3. +0
    -3
      webnotes/utils/email_lib/__init__.py
  4. +4
    -0
      webnotes/utils/email_lib/smtp.py

+ 1
- 4
core/doctype/communication/communication.py 파일 보기

@@ -71,15 +71,12 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
if sent_via: if sent_via:
if hasattr(sent_via, "get_sender"): if hasattr(sent_via, "get_sender"):
d.sender = sent_via.get_sender(d)
d.sender = sent_via.get_sender(d) or d.sender
if hasattr(sent_via, "get_subject"): if hasattr(sent_via, "get_subject"):
d.subject = sent_via.get_subject(d) d.subject = sent_via.get_subject(d)
if hasattr(sent_via, "get_content"): if hasattr(sent_via, "get_content"):
d.content = sent_via.get_content(d) d.content = sent_via.get_content(d)


if not d.sender:
d.sender = webnotes.session.user

from webnotes.utils.email_lib.smtp import get_email from webnotes.utils.email_lib.smtp import get_email
mail = get_email(d.recipients, sender=d.sender, subject=d.subject, mail = get_email(d.recipients, sender=d.sender, subject=d.subject,
msg=d.content) msg=d.content)


+ 55
- 43
public/js/wn/views/communication.js 파일 보기

@@ -227,52 +227,64 @@ wn.views.CommunicationComposer = Class.extend({
.find("[data-file-name]:checked"), function(element) { .find("[data-file-name]:checked"), function(element) {
return $(element).attr("data-file-name"); return $(element).attr("data-file-name");
}) })
_p.build(form_values.select_print_format || "", function(print_format_html) {
if(form_values.attach_document_print) {
var print_html = print_format_html
if(cint(wn.boot.send_print_in_body_and_attachment)) {
form_values.content = form_values.content
+ "<p></p><hr>" + print_html;
} else {
form_values.content = form_values.content + "<p>"
+ "Please see attachment for document details.</p>"
}
// if(form_values.attach_document_print) {
_p.build(form_values.select_print_format || "", function(print_format_html) {
me.send_email(btn, form_values, selected_attachments, print_format_html);
});
// } else {
// me.send_email(btn, form_values, selected_attachments);
// }
});
},
send_email: function(btn, form_values, selected_attachments, print_format_html) {
var me = this;
if(form_values.attach_document_print) {
var print_html = print_format_html;
if(cint(wn.boot.send_print_in_body_and_attachment)) {
form_values.content = form_values.content
+ "<p></p><hr>" + print_html;
} else {
form_values.content = form_values.content + "<p>"
+ "Please see attachment for document details.</p>"
}
} else {
var print_html = "";
}
wn.call({
method:"core.doctype.communication.communication.make",
args: {
sender: wn.user_info(user).fullname + " <" + wn.boot.profile.email + ">",
recipients: form_values.recipients,
subject: form_values.subject,
content: form_values.content,
doctype: me.doc.doctype,
name: me.doc.name,
lead: me.doc.lead,
contact: me.doc.contact,
company: me.doc.company || sys_defaults.company,
send_me_a_copy: form_values.send_me_a_copy,
send_email: form_values.send_email,
print_html: print_html,
attachments: selected_attachments
},
btn: btn,
callback: function(r) {
if(!r.exc) {
if(form_values.send_email)
msgprint("Email sent to " + form_values.recipients);
me.dialog.hide();
cur_frm.reload_doc();
} else { } else {
print_html = "";
msgprint("There were errors while sending email. Please try again.")
} }
wn.call({
method:"core.doctype.communication.communication.make",
args: {
sender: wn.user_info(user).fullname + " <" + wn.boot.profile.email + ">",
recipients: form_values.recipients,
subject: form_values.subject,
content: form_values.content,
doctype: me.doc.doctype,
name: me.doc.name,
lead: me.doc.lead,
contact: me.doc.contact,
company: me.doc.company || sys_defaults.company,
send_me_a_copy: form_values.send_me_a_copy,
send_email: form_values.send_email,
print_html: print_html,
attachments: selected_attachments
},
btn: btn,
callback: function(r) {
if(!r.exc) {
if(form_values.send_email)
msgprint("Email sent to " + form_values.recipients);
me.dialog.hide();
cur_frm.reload_doc();
} else {
msgprint("There were errors while sending email. Please try again.")
}
}
});
})
});
}
});
}, },
setup_earlier_reply: function() { setup_earlier_reply: function() {
var fields = this.dialog.fields_dict; var fields = this.dialog.fields_dict;
var comm_list = cur_frm.communication_view var comm_list = cur_frm.communication_view


+ 0
- 3
webnotes/utils/email_lib/__init__.py 파일 보기

@@ -30,9 +30,6 @@ def sendmail_md(recipients, sender=None, msg=None, subject=None):
def sendmail(recipients, sender='', msg='', subject='[No Subject]'): def sendmail(recipients, sender='', msg='', subject='[No Subject]'):
"""send an html email as multipart with attachments and all""" """send an html email as multipart with attachments and all"""
if webnotes.mute_emails or getattr(conf, "mute_emails", False):
return

from webnotes.utils.email_lib.smtp import get_email from webnotes.utils.email_lib.smtp import get_email
get_email(recipients, sender, msg, subject).send() get_email(recipients, sender, msg, subject).send()




+ 4
- 0
webnotes/utils/email_lib/smtp.py 파일 보기

@@ -231,6 +231,10 @@ class EMail:
def send(self, as_bulk=False): def send(self, as_bulk=False):
"""send the message or add it to Outbox Email""" """send the message or add it to Outbox Email"""
if webnotes.mute_emails or getattr(conf, "mute_emails", False):
webnotes.msgprint("Emails are muted")
return
import smtplib import smtplib
try: try:
SMTPServer().sess.sendmail(self.sender, self.recipients + (self.cc or []), SMTPServer().sess.sendmail(self.sender, self.recipients + (self.cc or []),


불러오는 중...
취소
저장