def user_add_mail(user, kwargs):
 user_role = {'SU': u'\u8d85\u7ea7\u7ba1\u7406\u5458', 'GA': u'\u7ec4\u7ba1\u7406\u5458', 'CU': u'\u666e\u901a\u7528\u6237'}
 mail_title = (u'\u606d\u559c\u4f60\u7684\u8df3\u677f\u673a\u7528\u6237 %s \u6dfb\u52a0\u6210\u529f Jumpserver' % user.name)
 mail_msg = (u'\n    Hi, %s\n        \u60a8\u7684\u7528\u6237\u540d\uff1a %s\n        \u60a8\u7684\u6743\u9650\uff1a %s\n        \u60a8\u7684web\u767b\u5f55\u5bc6\u7801\uff1a %s\n        \u60a8\u7684ssh\u5bc6\u94a5\u6587\u4ef6\u5bc6\u7801\uff1a %s\n        \u5bc6\u94a5\u4e0b\u8f7d\u5730\u5740\uff1a %s/juser/key/down/?uuid=%s\n        \u8bf4\u660e\uff1a \u8bf7\u767b\u9646\u8df3\u677f\u673a\u540e\u53f0\u4e0b\u8f7d\u5bc6\u94a5, \u7136\u540e\u4f7f\u7528\u5bc6\u94a5\u767b\u9646\u8df3\u677f\u673a\uff01\n    ' % (user.name, user.username, user_role.get(user.role, u'\u666e\u901a\u7528\u6237'), kwargs.get('password'), kwargs.get('ssh_key_pwd'), URL, user.uuid))
 send_mail(mail_title, mail_msg, MAIL_FROM, [user.email], fail_silently=False)

def user_add_mail ( user , kwargs ) : user_role = { 'SU' : u'\u8d85\u7ea7\u7ba1\u7406\u5458' , 'GA' : u'\u7ec4\u7ba1\u7406\u5458' , 'CU' : u'\u666e\u901a\u7528\u6237' } mail_title = ( u'\u606d\u559c\u4f60\u7684\u8df3\u677f\u673a\u7528\u6237 %s \u6dfb\u52a0\u6210\u529f Jumpserver' % user . name ) mail_msg = ( u'\n    Hi, %s\n        \u60a8\u7684\u7528\u6237\u540d\uff1a %s\n        \u60a8\u7684\u6743\u9650\uff1a %s\n        \u60a8\u7684web\u767b\u5f55\u5bc6\u7801\uff1a %s\n        \u60a8\u7684ssh\u5bc6\u94a5\u6587\u4ef6\u5bc6\u7801\uff1a %s\n        \u5bc6\u94a5\u4e0b\u8f7d\u5730\u5740\uff1a %s/juser/key/down/?uuid=%s\n        \u8bf4\u660e\uff1a \u8bf7\u767b\u9646\u8df3\u677f\u673a\u540e\u53f0\u4e0b\u8f7d\u5bc6\u94a5, \u7136\u540e\u4f7f\u7528\u5bc6\u94a5\u767b\u9646\u8df3\u677f\u673a\uff01\n    ' % ( user . name , user . username , user_role . get ( user . role , u'\u666e\u901a\u7528\u6237' ) , kwargs . get ( 'password' ) , kwargs . get ( 'ssh_key_pwd' ) , URL , user . uuid ) ) send_mail ( mail_title , mail_msg , MAIL_FROM , [ user . email ] , fail_silently = False )
add user send mail .