瀏覽代碼

云存添加邮箱短句修改1

chenshibin 4 年之前
父節點
當前提交
ea526d933b
共有 2 個文件被更改,包括 31 次插入38 次删除
  1. 16 18
      Controller/CloudStorage.py
  2. 15 20
      Object/AWS/S3Email.py

+ 16 - 18
Controller/CloudStorage.py

@@ -790,7 +790,7 @@ class CloudStorageView(View):
 
                     order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['尊重的客户,您的'+UID+'设备在'+datetime+'已成功购买云存套餐,特此通知。', 'Dear customer, your '+UID+' device has successfully purchased the cloud storage package at '+datetime+', hereby notified.']
+                    sys_msg_text_list = ['温馨提示:尊重的客户,您的'+UID+'设备在'+datetime+'已成功购买云存套餐', 'Warm tips: Dear customers, your '+UID+' device has successfully purchased the cloud storage package in '+datetime]
                     self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
                     red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
                     if lang != 'cn':
@@ -896,8 +896,8 @@ class CloudStorageView(View):
 
                 order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
                 datetime = time.strftime("%Y-%m-%d", time.localtime())
-                sys_msg_text_list = ['尊重的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐,特此通知。',
-                                     'Dear customer, your ' + UID + ' device has successfully purchased the cloud storage package at ' + datetime + ', hereby notified.']
+                sys_msg_text_list = ['温馨提示:尊重的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
+                                     'Warm tips: Dear customers, your '+UID+' device has successfully purchased the cloud storage package in '+datetime]
 
                 self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
 
@@ -999,8 +999,8 @@ class CloudStorageView(View):
 
                     order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['尊重的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐,特此通知。',
-                                         'Dear customer, your ' + UID + ' device has successfully purchased the cloud storage package at ' + datetime + ', hereby notified.']
+                    sys_msg_text_list = ['温馨提示:尊重的客户,您的' + UID + '设备在' + datetime + '已成功购买云存套餐',
+                                         'Warm tips: Dear customers, your '+UID+' device has successfully purchased the cloud storage package in '+datetime]
                     self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
                     return HttpResponse(pay.xml_to_dict({'return_code': 'SUCCESS', 'return_msg': 'OK'}))
             else:
@@ -1280,8 +1280,8 @@ class CloudStorageView(View):
                 #     UIDMainUser.objects.create(**uid_main_dict)
 
                 datetime = time.strftime("%Y-%m-%d", time.localtime())
-                sys_msg_text_list = ['尊重的客户,您的' + uid + '设备在' + datetime + '已成功购买云存套餐,特此通知。',
-                                     'Dear customer, your ' + uid + ' device has successfully purchased the cloud storage package at ' + datetime + ', hereby notified.']
+                sys_msg_text_list = ['温馨提示:尊重的客户,您的' + uid + '设备在' + datetime + '已成功购买云存套餐',
+                                     'Warm tips: Dear customers, your '+uid+' device has successfully purchased the cloud storage package in '+datetime]
                 # return response.json(0)
                 returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
                 if pay_type == 10:
@@ -1292,8 +1292,8 @@ class CloudStorageView(View):
                     )
                     returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=10&lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['尊重的客户,您的' + uid + '设备在' + datetime + '已成功体验云存,特此通知。',
-                                         'Dear customers, your '+uid+' device has successfully experienced cloud storage at '+datetime+', hereby notified.']
+                    sys_msg_text_list = ['温馨提示:尊重的客户,您的' + uid + '设备在' + datetime + '已成功体验云存',
+                                         'Warm tips: respected customers, your '+uid+' device has successfully experienced cloud storage in '+datetime]
 
                 if pay_type == 11:
                     update_dict = {}
@@ -1303,8 +1303,8 @@ class CloudStorageView(View):
                     returnurl = "{SERVER_DOMAIN_SSL}cloudstorage/payOK?paytype=11&lang={lang}".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL,lang=lang)
 
                     datetime = time.strftime("%Y-%m-%d", time.localtime())
-                    sys_msg_text_list = ['尊重的客户,您的' + uid + '设备在' + datetime + '已成功兑换云存,特此通知。',
-                                         'Dear customer, your '+uid+' device has been redeemed for cloud deposit at '+datetime+', hereby notified.']
+                    sys_msg_text_list = ['温馨提示:尊重的客户,您的' + uid + '设备在' + datetime + '已成功兑换云存',
+                                         'Warm tips: Dear customers, your '+uid+' device has been successfully converted to cloud deposit at '+datetime]
 
 
                 self.do_vod_msg_Notice(uid, channel, userID, lang, sys_msg_text_list)
@@ -1455,7 +1455,7 @@ class CloudStorageView(View):
                 username = user.username
                 data_valid = DataValid()
                 if data_valid.email_validate(username):
-                    S3Email.faEmail(sys_msg_text,username)
+                    S3Email().faEmail(sys_msg_text, username)
                 elif data_valid.mobile_validate(username):
                     params = u'{"devname":"' + uid + '","submittime":"' + time.strftime("%Y-%m-%d",time.localtime()) + '"}'
                     self.sendMessage(username, params, 'SMS_217405528')
@@ -1491,12 +1491,10 @@ class CloudStorageView(View):
             for oo in oqlist:
                 if ub['id'] == oo['uid_bucket_id']:
                     if ub['bucket__area'] == 'cn':
-                        sys_msg_text = "尊重的客户,您" + ub['uid'] + "设备的云存套餐将在" + time.strftime("%Y-%m-%d",
-                                                                                           ub['endTime']) + "到期,特此通知。"
+                        sys_msg_text = "温馨提示:尊重的客户,您" + ub['uid'] + "设备的云存套餐将在" + time.strftime("%Y-%m-%d",
+                                                                                           ub['endTime']) + "到期"
                     else:
-                        sys_msg_text = "Dear customer, the cloud storage package of your " + ub[
-                            'uid'] + " device will expire in " + time.strftime("%Y-%m-%d",
-                                                                               ub['endTime']) + ", hereby notified."
+                        sys_msg_text = "Warm tips: Dear customers, the cloud storage package of your " + ub['uid'] + " device will expire at " + time.strftime("%Y-%m-%d",ub['endTime'])
                     uq_list.append(SysMsgModel(
                         userID_id=oo['userID_id'],
                         addTime=now_time,
@@ -1513,7 +1511,7 @@ class CloudStorageView(View):
                         data_valid = DataValid()
 
                         if data_valid.email_validate(username):
-                            S3Email.faEmail(sys_msg_text, username)
+                            S3Email().faEmail(sys_msg_text, username)
                         elif data_valid.mobile_validate(username):
                             params = u'{"devname":"' + ub['uid'] + '","submittime":"' + time.strftime("%Y-%m-%d",
                                                                                                       ub[

+ 15 - 20
Object/AWS/S3Email.py

@@ -5,21 +5,16 @@ from email.mime.text import MIMEText
 
 class S3Email:
 
-   def __init__(self, *args, **kwargs):
-       SENDER = 'rdpublic@ansjer.com'  # 邮箱名
-       SENDERNAME = 'rdpublic@ansjer.com'
-       USERNAME_SMTP = "AKIA2E67UIMD6MOSFKXW"  # 带有邮件权限的 IAM 帐号
-       PASSWORD_SMTP = "BHuQ6EQTtFK4qh46o9omO9ZzO3NXzjk/JCWLXnVFmqzM"  # 带有邮件权限的 IAM 密码
-       PORT = 587
-       HOST = "email-smtp.us-east-1.amazonaws.com"
 
-
-   def faEmail(self, content ,RECIPIENT):
-
-        SUBJECT = 'Amazon SES Error (Python smtplib)'
-        BODY_TEXT = ("Amazon SES Test\r\n"
-                     "This email was sent through the Amazon SES SMTP "
-                     "Interface using the Python smtplib package."
+   def faEmail(self, sys_msg_text ,username):
+        SENDER = 'rdpublic@ansjer.com'  # 邮箱名
+        SENDERNAME = 'rdpublic@ansjer.com'
+        USERNAME_SMTP = 'AKIA2E67UIMD6MOSFKXW'  # 带有邮件权限的 IAM 帐号
+        PASSWORD_SMTP = 'BHuQ6EQTtFK4qh46o9omO9ZzO3NXzjk/JCWLXnVFmqzM'  # 带有邮件权限的 IAM 密码
+        PORT = '587'
+        HOST = 'email-smtp.us-east-1.amazonaws.com'
+        SUBJECT = sys_msg_text
+        BODY_TEXT = (sys_msg_text
                      )
         BODY_HTML = """<html>
         <head></head>
@@ -27,24 +22,24 @@ class S3Email:
           <h1>{}<h1>
         </body>
         </html>
-                    """.format(content)
+                    """.format(sys_msg_text)
 
         msg = MIMEMultipart('alternative')
         msg['Subject'] = SUBJECT
-        msg['From'] = email.utils.formataddr((self.SENDERNAME, self.SENDER))
-        msg['To'] = RECIPIENT
+        msg['From'] = email.utils.formataddr((SENDERNAME, SENDER))
+        msg['To'] = username
         part1 = MIMEText(BODY_TEXT, 'plain')
         part2 = MIMEText(BODY_HTML, 'html')
         msg.attach(part1)
         msg.attach(part2)
 
         try:
-            server = smtplib.SMTP(self.HOST, self.PORT)
+            server = smtplib.SMTP(HOST, PORT)
             server.ehlo()
             server.starttls()
             server.ehlo()
-            server.login(self.USERNAME_SMTP, self.PASSWORD_SMTP)
-            server.sendmail(self.SENDER, RECIPIENT, msg.as_string())
+            server.login(USERNAME_SMTP, PASSWORD_SMTP)
+            server.sendmail(SENDER, username, msg.as_string())
             server.close()
         except Exception as e:
             print("Error: ", e)