Example #1
0
	def validate_outgoing(self):
		"""
			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:
				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('Login Id or Mail Password missing. Please enter and try again.')
				webnotes.msgprint(e)
			
			try:
				sess = out_email.smtp_connect()
				try:
					sess.quit()
				except:
					pass
			except _socket.error, e:
				# Invalid mail server -- due to refusing connection
				webnotes.msgprint('Invalid Outgoing Mail Server. Please rectify and try again.')
				webnotes.msgprint(e)
Example #2
0
	def validate_outgoing(self):
		"""
			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:
				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('Login Id or Mail Password missing. Please enter and try again.')
				webnotes.msgprint(e)
			
			try:
				sess = out_email.smtp_connect()
				try:
					sess.quit()
				except:
					pass
			except _socket.error, e:
				# Invalid mail server -- due to refusing connection
				webnotes.msgprint('Invalid Outgoing Mail Server. Please rectify and try again.')
				webnotes.msgprint(e)
	def validate_outgoing(self):
		"""
			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
			
			# exceptions are handled in smtp_connect
			sess = out_email.smtp_connect()
			
			try:
				sess.quit()
			except:
				pass