Fixed version conflict
This commit is contained in:
commit
aef76fbb3f
5 changed files with 36 additions and 22 deletions
|
|
@ -360,7 +360,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**.
|
||||
|
||||
|
||||
|
|
@ -397,11 +397,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 = []
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
# 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)
|
||||
|
||||
_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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue