瀏覽代碼

Merge pull request #1318 from anandpdoshi/email-fixes

send upto 100 bulk emails at a time, and fix to validate email address
version-14
Anand Doshi 9 年之前
父節點
當前提交
bc4fe0a618
共有 2 個檔案被更改,包括 9 行新增2 行删除
  1. +4
    -1
      frappe/email/bulk.py
  2. +5
    -1
      frappe/utils/__init__.py

+ 4
- 1
frappe/email/bulk.py 查看文件

@@ -230,7 +230,7 @@ def flush(from_test=False):
frappe.db.sql("""update `tabBulk Email` set status='Expired'
where datediff(curdate(), creation) > 3""", auto_commit=auto_commit)

for i in xrange(500):
for i in xrange(100):
email = frappe.db.sql("""select * from `tabBulk Email` where
status='Not Sent' and ifnull(send_after, "2000-01-01 00:00:00") < %s
order by priority desc, creation asc limit 1 for update""", now_datetime(), as_dict=1)
@@ -265,6 +265,9 @@ def flush(from_test=False):
frappe.db.sql("""update `tabBulk Email` set status='Error', error=%s
where name=%s""", (unicode(e), email["name"]), auto_commit=auto_commit)

finally:
frappe.db.commit()

def clear_outbox():
"""Remove mails older than 31 days in Outbox. Called daily via scheduler."""
frappe.db.sql("""delete from `tabBulk Email` where


+ 5
- 1
frappe/utils/__init__.py 查看文件

@@ -75,7 +75,11 @@ def validate_email_add(email_str, throw=False):
match = re.match("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", email.lower())

if not match:
return False
if throw:
frappe.throw(frappe._("{0} is not a valid email id").format(email),
frappe.InvalidEmailAddressError)
else:
return False

matched = match.group(0)



Loading…
取消
儲存