added unsubscribed fields in Lead and Contact and cleaned up sendmail function

This commit is contained in:
Rushabh Mehta
2012-08-02 18:03:12 +05:30
parent a4fe7180f4
commit f0018b5e05
21 changed files with 70 additions and 562 deletions

View File

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

View File

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