ソースを参照

Merge branch 'hotfix'

version-14
Nabin Hait 8年前
コミット
a1e9b4d448
5個のファイルの変更37行の追加23行の削除
  1. +4
    -4
      frappe/__init__.py
  2. +3
    -1
      frappe/core/doctype/user/user.py
  3. +7
    -5
      frappe/email/__init__.py
  4. +22
    -12
      frappe/email/smtp.py
  5. +1
    -1
      frappe/utils/backups.py

+ 4
- 4
frappe/__init__.py ファイルの表示

@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template

__version__ = "7.0.33"
__version__ = "7.0.34"

local = Local()

@@ -359,7 +359,7 @@ def sendmail(recipients=(), sender="", subject="No Subject", message="No Message
unsubscribe_method=None, unsubscribe_params=None, unsubscribe_message=None,
attachments=None, content=None, doctype=None, name=None, reply_to=None,
cc=(), show_as_cc=(), message_id=None, in_reply_to=None, send_after=None, expose_recipients=False,
send_priority=1, communication=None):
send_priority=1, communication=None, retry=1):
"""Send email using user's default **Email Account** or global default **Email Account**.


@@ -396,11 +396,11 @@ def sendmail(recipients=(), sender="", subject="No Subject", message="No Message
if as_markdown:
frappe.email.sendmail_md(recipients, sender=sender,
subject=subject, msg=content or message, attachments=attachments, reply_to=reply_to,
cc=cc, message_id=message_id, in_reply_to=in_reply_to)
cc=cc, message_id=message_id, in_reply_to=in_reply_to, retry=retry)
else:
frappe.email.sendmail(recipients, sender=sender,
subject=subject, msg=content or message, attachments=attachments, reply_to=reply_to,
cc=cc, message_id=message_id, in_reply_to=in_reply_to)
cc=cc, message_id=message_id, in_reply_to=in_reply_to, retry=retry)

whitelisted = []
guest_methods = []


+ 3
- 1
frappe/core/doctype/user/user.py ファイルの表示

@@ -209,9 +209,11 @@ class User(Document):
from frappe.utils import get_url

link = self.reset_password()

self.send_login_mail(_("Verify Your Account"), "templates/emails/new_user.html",
{"link": link, "site_url": get_url()})


def send_login_mail(self, subject, template, add_args, now=None):
"""send mail with login details"""
from frappe.utils.user import get_user_fullname
@@ -238,7 +240,7 @@ class User(Document):

frappe.sendmail(recipients=self.email, sender=sender, subject=subject,
message=frappe.get_template(template).render(args),
delayed=(not now) if now!=None else self.flags.delay_emails)
delayed=(not now) if now!=None else self.flags.delay_emails, retry=3)

def a_system_manager_should_exist(self):
if not self.get_other_system_managers():


+ 7
- 5
frappe/email/__init__.py ファイルの表示

@@ -9,20 +9,22 @@ from frappe.email.smtp import send
from frappe.utils import markdown

def sendmail_md(recipients, sender=None, msg=None, subject=None, attachments=None, content=None,
reply_to=None, cc=(), message_id=None, in_reply_to=None):
reply_to=None, cc=(), message_id=None, in_reply_to=None, retry=1):
"""send markdown email"""
sendmail(recipients, sender, markdown(content or msg), subject, attachments, reply_to=reply_to, cc=cc)
sendmail(recipients, sender, markdown(content or msg), subject, attachments,
reply_to=reply_to, cc=cc, retry=retry)

def sendmail(recipients, sender='', msg='', subject='[No Subject]', attachments=None, content=None,
reply_to=None, cc=(), message_id=None, in_reply_to=None):
reply_to=None, cc=(), message_id=None, in_reply_to=None, retry=1):
"""send an html email as multipart with attachments and all"""
mail = get_email(recipients, sender, content or msg, subject, attachments=attachments, reply_to=reply_to, cc=cc)
mail = get_email(recipients, sender, content or msg, subject, attachments=attachments,
reply_to=reply_to, cc=cc)
if message_id:
mail.set_message_id(message_id)
if in_reply_to:
mail.set_in_reply_to(in_reply_to)

send(mail)
send(mail, retry=retry)

def sendmail_to_system_managers(subject, content):
send(get_email(get_system_managers(), None, content, subject))


+ 22
- 12
frappe/email/smtp.py ファイルの表示

@@ -10,7 +10,7 @@ import _socket, sys
from frappe.utils import cint
from frappe import _

def send(email, append_to=None):
def send(email, append_to=None, retry=1):
"""send the message or add it to Outbox Email"""
if frappe.flags.in_test:
frappe.flags.sent_mail = email.as_string()
@@ -20,20 +20,30 @@ def send(email, append_to=None):
frappe.msgprint(_("Emails are muted"))
return

try:
smtpserver = SMTPServer(append_to=append_to)
def _send(retry):
try:
smtpserver = SMTPServer(append_to=append_to)

# validate is called in as_string
email_body = email.as_string()

smtpserver.sess.sendmail(email.sender, email.recipients + (email.cc or []), email_body)
except smtplib.SMTPSenderRefused:
frappe.throw(_("Invalid login or password"), title='Email Failed')
raise
except smtplib.SMTPRecipientsRefused:
frappe.msgprint(_("Invalid recipient address"), title='Email Failed')
raise
except smtplib.SMTPServerDisconnected:
if not retry:
raise
else:
retry = retry - 1
_send(retry)

# validate is called in as_string
email_body = email.as_string()
_send(retry)

smtpserver.sess.sendmail(email.sender, email.recipients + (email.cc or []), email_body)

except smtplib.SMTPSenderRefused:
frappe.throw(_("Invalid login or password"), title='Email Failed')
raise
except smtplib.SMTPRecipientsRefused:
frappe.msgprint(_("Invalid recipient address"), title='Email Failed')
raise

def get_outgoing_email_account(raise_exception_not_set=True, append_to=None):
"""Returns outgoing email account based on `append_to` or the default


+ 1
- 1
frappe/utils/backups.py ファイルの表示

@@ -166,7 +166,7 @@ def scheduled_backup(older_than=6, ignore_files=False, backup_path_db=None, back
return odb

def new_backup(older_than=6, ignore_files=False, backup_path_db=None, backup_path_files=None, backup_path_private_files=None, force=False):
delete_temp_backups(older_than = frappe.conf.keep_backups_for_hours or 48)
delete_temp_backups(older_than = frappe.conf.keep_backups_for_hours or 24)
odb = BackupGenerator(frappe.conf.db_name, frappe.conf.db_name,\
frappe.conf.db_password,
backup_path_db=backup_path_db, backup_path_files=backup_path_files,


読み込み中…
キャンセル
保存