Example #1
0
	def send_login_mail(self, subject, template, add_args):
		"""send mail with login details"""
		from webnotes.profile import get_user_fullname
		from webnotes.utils import get_url
		
		mail_titles = webnotes.get_hooks().get("login_mail_title", [])
		title = webnotes.conn.get_default('company') or (mail_titles and mail_titles[0]) or ""
		
		full_name = get_user_fullname(webnotes.session['user'])
		if full_name == "Guest":
			full_name = "Administrator"
	
		args = {
			'first_name': self.doc.first_name or self.doc.last_name or "user",
			'user': self.doc.name,
			'title': title,
			'login_url': get_url(),
			'user_fullname': full_name
		}
		
		args.update(add_args)
		
		sender = webnotes.session.user not in ("Administrator", "Guest") and webnotes.session.user or None
		
		webnotes.sendmail(recipients=self.doc.email, sender=sender, subject=subject, 
			message=webnotes.get_template(template).render(args))
Example #2
0
def notify(arg=None):
	from webnotes.utils import cstr, get_fullname, get_url
	
	webnotes.sendmail(\
		recipients=[webnotes.conn.get_value("Profile", arg["contact"], "email") or arg["contact"]],
		sender= webnotes.conn.get_value("Profile", webnotes.session.user, "email"),
		subject="New Message from " + get_fullname(webnotes.user.name),
		message=webnotes.get_template("templates/emails/new_message.html").render({
			"from": get_fullname(webnotes.user.name),
			"message": arg['txt'],
			"link": get_url()
		})
	)