예제 #1
0
	def push(self, callback, errback, pluginname, subject, body="", attachments=[]):
		from Plugins.Extensions.PushService.plugin import NAME, VERSION, SUPPORT, DONATE
		
		# Set SMTP parameters
		mailconf = {}
		mailconf["host"]     = self.getValue('smtpserver')
		mailconf["port"]     = self.getValue('smtpport')
		mailconf["username"] = self.getValue('username')
		mailconf["password"] = self.getValue('password')
		mailconf["ssl"]      = self.getValue('smtpssl')
		mailconf["tls"]      = self.getValue('smtptls')
		mailconf["timeout"]  = self.getValue('timeout')
		
		# Create message object
		from_addr = self.getValue('mailfrom')
		to_addrs = [self.getValue('mailto') or from_addr]
		
		# Prepare message
		if body == "": body = subject
		subject = MAIL_HEADER_TEMPLATE.format( **{'box': config.pushservice.boxname.value, 'name': NAME, 'plugin': pluginname, 'subject': subject} )
		body    = MAIL_BODY_TEMPLATE.format( **{'body': str(body), 'name': NAME, 'version': VERSION, 'plugin': pluginname, 'support': SUPPORT, 'donate': DONATE} )
		message = Message(from_addr, to_addrs, subject, body) #TODO change mime="text/plain", charset="utf-8")
		if attachments:
			for attachment in attachments:
				message.attach(attachment) #TODO change mime=None, charset=None, content=None):
		
		# Send message
		print _("[PushService] PushMail: Sending message: %s") % subject
		deferred, connector = sendmail(mailconf, message)
		
		# Add callbacks
		deferred.addCallback(callback)
		deferred.addErrback(errback)
		
		self.connectors.append(connector)
예제 #2
0
	def push(self, callback, errback, pluginname, subject, body="", attachments=[]):
		from Plugins.Extensions.PushService.plugin import NAME, VERSION, SUPPORT, DONATE
		
		# Set SMTP parameters
		mailconf = {}
		mailconf["host"]     = self.getValue('smtpserver')
		mailconf["port"]     = self.getValue('smtpport')
		mailconf["username"] = self.getValue('username')
		mailconf["password"] = self.getValue('password')
		mailconf["ssl"]      = self.getValue('smtpssl')
		mailconf["tls"]      = self.getValue('smtptls')
		mailconf["timeout"]  = self.getValue('timeout')
		
		# Create message object
		from_addr = self.getValue('mailfrom')
		to_addrs = [self.getValue('mailto') or from_addr]
		
		# Prepare message
		if body == "": body = subject
		subject = MAIL_HEADER_TEMPLATE.format( **{'box': config.pushservice.boxname.value, 'name': NAME, 'plugin': pluginname, 'subject': subject} )
		body    = MAIL_BODY_TEMPLATE.format( **{'body': str(body), 'name': NAME, 'version': VERSION, 'plugin': pluginname, 'support': SUPPORT, 'donate': DONATE} )
		message = Message(from_addr, to_addrs, subject, body) #TODO change mime="text/plain", charset="utf-8")
		if attachments:
			for attachment in attachments:
				message.attach(attachment) #TODO change mime=None, charset=None, content=None):
		
		# Send message
		print _("PushService PushMail: Sending message: %s") % subject
		deferred, connector = sendmail(mailconf, message)
		
		# Add callbacks
		deferred.addCallback(callback)
		deferred.addErrback(errback)
		
		self.connectors.append(connector)