mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-31 23:33:43 +00:00
added unsubscribed fields in Lead and Contact and cleaned up sendmail function
This commit is contained in:
@@ -415,7 +415,6 @@ class DocType:
|
||||
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
try:
|
||||
#webnotes.msgprint('in send')
|
||||
sendmail(
|
||||
recipients=recipient_list,
|
||||
sender='notifications+email_digest@erpnext.com',
|
||||
|
||||
@@ -24,44 +24,24 @@ class DocType:
|
||||
self.doc,self.doclist = doc,doclist
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
Checks connectivity to email servers before saving
|
||||
"""
|
||||
"""Checks connectivity to email servers before saving"""
|
||||
self.validate_outgoing()
|
||||
self.validate_incoming()
|
||||
|
||||
|
||||
def validate_outgoing(self):
|
||||
"""
|
||||
Checks incoming email settings
|
||||
"""
|
||||
"""Checks incoming email settings"""
|
||||
if self.doc.outgoing_mail_server:
|
||||
from webnotes.utils import cint
|
||||
import _socket
|
||||
from webnotes.utils.email_lib.send import EMail
|
||||
import smtplib
|
||||
out_email = EMail()
|
||||
out_email.server = self.doc.outgoing_mail_server.encode('utf-8')
|
||||
out_email.port = cint(self.doc.mail_port)
|
||||
out_email.use_ssl = self.doc.use_ssl
|
||||
try:
|
||||
err_msg = "Login Id or Mail Password missing. Please enter and try again."
|
||||
if not (self.doc.mail_login and self.doc.mail_password):
|
||||
raise AttributeError, err_msg
|
||||
out_email.login = self.doc.mail_login.encode('utf-8')
|
||||
out_email.password = self.doc.mail_password.encode('utf-8')
|
||||
except AttributeError, e:
|
||||
webnotes.msgprint(err_msg)
|
||||
raise e
|
||||
from webnotes.utils.email_lib.smtp import SMTPServer
|
||||
smtpserver = SMTPServer(login = self.doc.mail_login,
|
||||
password = self.doc.mail_password,
|
||||
server = self.doc.outgoing_mail_server,
|
||||
port = cint(self.doc.mail_port),
|
||||
use_ssl = self.doc.use_ssl
|
||||
)
|
||||
|
||||
# exceptions are handled in smtp_connect
|
||||
sess = out_email.smtp_connect()
|
||||
|
||||
try:
|
||||
sess.quit()
|
||||
except:
|
||||
pass
|
||||
|
||||
# exceptions are handled in session connect
|
||||
sess = smtpserver.sess
|
||||
|
||||
def validate_incoming(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user