Exemplo n.º 1
0
def email_sending(project_name, frequency, date_start, date_end, progress,
                  number_of_drafts, update):

    holiday = dataent.db.sql(
        """SELECT holiday_date FROM `tabHoliday` where holiday_date = CURDATE();"""
    )
    msg = "<p>Project Name: " + project_name + "</p><p>Frequency: " + " " + frequency + "</p><p>Update Reminder:" + " " + str(
        date_start) + "</p><p>Expected Date End:" + " " + str(
            date_end) + "</p><p>Percent Progress:" + " " + str(
                progress) + "</p><p>Number of Updates:" + " " + str(len(
                    update)) + "</p>" + "</p><p>Number of drafts:" + " " + str(
                        number_of_drafts) + "</p>"
    msg += """</u></b></p><table class='table table-bordered'><tr>
                <th>Project ID</th><th>Date Updated</th><th>Time Updated</th><th>Project Status</th><th>Notes</th>"""
    for updates in update:
        msg += "<tr><td>" + str(updates[0]) + "</td><td>" + str(
            updates[1]) + "</td><td>" + str(updates[2]) + "</td><td>" + str(
                updates[3]) + "</td>" + "</td><td>" + str(
                    updates[4]) + "</td></tr>"

    msg += "</table>"
    if len(holiday) == 0:
        email = dataent.db.sql(
            """SELECT user from `tabProject User` WHERE parent = %s;""",
            project_name)
        for emails in email:
            dataent.sendmail(recipients=emails,
                             subject=dataent._(project_name + ' ' + 'Summary'),
                             message=msg)
    else:
        pass
Exemplo n.º 2
0
def _notify(doc,
            print_html=None,
            print_format=None,
            attachments=None,
            recipients=None,
            cc=None,
            bcc=None):

    prepare_to_notify(doc, print_html, print_format, attachments)

    if doc.outgoing_email_account.send_unsubscribe_message:
        unsubscribe_message = _("Leave this conversation")
    else:
        unsubscribe_message = ""

    dataent.sendmail(
        recipients=(recipients or []),
        cc=(cc or []),
        bcc=(bcc or []),
        expose_recipients="header",
        sender=doc.sender,
        reply_to=doc.incoming_email_account,
        subject=doc.subject,
        content=doc.content,
        reference_doctype=doc.reference_doctype,
        reference_name=doc.reference_name,
        attachments=doc.attachments,
        message_id=doc.message_id,
        unsubscribe_message=unsubscribe_message,
        delayed=True,
        communication=doc.name,
        read_receipt=doc.read_receipt,
        is_notification=True if doc.sent_or_received == "Received" else False,
        print_letterhead=dataent.flags.print_letterhead)
Exemplo n.º 3
0
    def test_cc_footer(self):
        #test if sending with cc's makes it into header
        dataent.sendmail(recipients=['*****@*****.**'],
                         cc=['*****@*****.**'],
                         sender="*****@*****.**",
                         reference_doctype='User',
                         reference_name="Administrator",
                         subject='Testing Email Queue',
                         message='This is mail is queued!',
                         unsubscribe_message="Unsubscribe",
                         expose_recipients="footer",
                         now=True)
        email_queue = dataent.db.sql(
            """select name from `tabEmail Queue` where status='Sent'""",
            as_dict=1)
        self.assertEqual(len(email_queue), 1)
        queue_recipients = [
            r.recipient for r in dataent.db.sql(
                """select recipient from `tabEmail Queue Recipient`
			where status='Sent'""",
                as_dict=1)
        ]
        self.assertTrue('*****@*****.**' in queue_recipients)
        self.assertTrue('*****@*****.**' in queue_recipients)

        self.assertTrue(
            'This email was sent to [email protected] and copied to [email protected]'
            in dataent.safe_decode(dataent.flags.sent_mail))
Exemplo n.º 4
0
    def send_email(self):
        """
			Sends the link to backup file located at epaas/backups
		"""
        from dataent.email import get_system_managers

        recipient_list = get_system_managers()
        db_backup_url = get_url(
            os.path.join('backups', os.path.basename(self.backup_path_db)))
        files_backup_url = get_url(
            os.path.join('backups', os.path.basename(self.backup_path_files)))

        msg = """Hello,

Your backups are ready to be downloaded.

1. [Click here to download the database backup](%(db_backup_url)s)
2. [Click here to download the files backup](%(files_backup_url)s)

This link will be valid for 24 hours. A new backup will be available for
download only after 24 hours.""" % {
            "db_backup_url": db_backup_url,
            "files_backup_url": files_backup_url
        }

        datetime_str = datetime.fromtimestamp(
            os.stat(self.backup_path_db).st_ctime)
        subject = datetime_str.strftime(
            "%d/%m/%Y %H:%M:%S") + """ - Backup ready to be downloaded"""

        dataent.sendmail(recipients=recipient_list, msg=msg, subject=subject)
        return recipient_list
Exemplo n.º 5
0
    def test_cc_header(self):
        #test if sending with cc's makes it into header
        dataent.sendmail(recipients=['*****@*****.**'],
                         cc=['*****@*****.**'],
                         sender="*****@*****.**",
                         reference_doctype='User',
                         reference_name="Administrator",
                         subject='Testing Email Queue',
                         message='This is mail is queued!',
                         unsubscribe_message="Unsubscribe",
                         expose_recipients="header")
        email_queue = dataent.db.sql(
            """select name from `tabEmail Queue` where status='Not Sent'""",
            as_dict=1)
        self.assertEqual(len(email_queue), 1)
        queue_recipients = [
            r.recipient for r in dataent.db.sql(
                """select recipient from `tabEmail Queue Recipient`
			where status='Not Sent'""",
                as_dict=1)
        ]
        self.assertTrue('*****@*****.**' in queue_recipients)
        self.assertTrue('*****@*****.**' in queue_recipients)

        message = dataent.db.sql("""select message from `tabEmail Queue`
			where status='Not Sent'""",
                                 as_dict=1)[0].message
        self.assertTrue('To: [email protected]' in message)
        self.assertTrue('CC: [email protected]' in message)
Exemplo n.º 6
0
def notify_unreplied():
	"""Sends email notifications if there are unreplied Communications
		and `notify_if_unreplied` is set as true."""

	for email_account in dataent.get_all("Email Account", "name", filters={"enable_incoming": 1, "notify_if_unreplied": 1}):
		email_account = dataent.get_doc("Email Account", email_account.name)
		if email_account.append_to:

			# get open communications younger than x mins, for given doctype
			for comm in dataent.get_all("Communication", "name", filters=[
					{"sent_or_received": "Received"},
					{"reference_doctype": email_account.append_to},
					{"unread_notification_sent": 0},
					{"email_account":email_account.name},
					{"creation": ("<", datetime.now() - timedelta(seconds = (email_account.unreplied_for_mins or 30) * 60))},
					{"creation": (">", datetime.now() - timedelta(seconds = (email_account.unreplied_for_mins or 30) * 60 * 3))}
				]):
				comm = dataent.get_doc("Communication", comm.name)

				if dataent.db.get_value(comm.reference_doctype, comm.reference_name, "status")=="Open":
					# if status is still open
					dataent.sendmail(recipients=email_account.get_unreplied_notification_emails(),
						content=comm.content, subject=comm.subject, doctype= comm.reference_doctype,
						name=comm.reference_name)

				# update flag
				comm.db_set("unread_notification_sent", 1)
Exemplo n.º 7
0
    def email_salary_slip(self):
        receiver = dataent.db.get_value("Employee", self.employee,
                                        "prefered_email")

        if receiver:
            email_args = {
                "recipients": [receiver],
                "message":
                _("Please see attachment"),
                "subject":
                'Salary Slip - from {0} to {1}'.format(self.start_date,
                                                       self.end_date),
                "attachments": [
                    dataent.attach_print(self.doctype,
                                         self.name,
                                         file_name=self.name)
                ],
                "reference_doctype":
                self.doctype,
                "reference_name":
                self.name
            }
            if not dataent.flags.in_test:
                enqueue(method=dataent.sendmail,
                        queue='short',
                        timeout=300,
                        is_async=True,
                        **email_args)
            else:
                dataent.sendmail(**email_args)
        else:
            msgprint(
                _("{0}: Employee email not found, hence email not sent").
                format(self.employee_name))
Exemplo n.º 8
0
    def send_login_mail(self, subject, template, add_args, now=None):
        """send mail with login details"""
        from dataent.utils.user import get_user_fullname
        from dataent.utils import get_url

        full_name = get_user_fullname(dataent.session['user'])
        if full_name == "Guest":
            full_name = "Administrator"

        args = {
            'first_name': self.first_name or self.last_name or "user",
            'user': self.name,
            'title': subject,
            'login_url': get_url(),
            'user_fullname': full_name
        }

        args.update(add_args)

        sender = dataent.session.user not in STANDARD_USERS and get_formatted_email(
            dataent.session.user) or None

        dataent.sendmail(
            recipients=self.email,
            sender=sender,
            subject=subject,
            template=template,
            args=args,
            header=[subject, "green"],
            delayed=(not now) if now != None else self.flags.delay_emails,
            retry=3)
Exemplo n.º 9
0
    def send(self):
        # send email only to enabled users
        valid_users = [
            p[0] for p in dataent.db.sql("""select name from `tabUser`
			where enabled=1""")
        ]
        recipients = list(
            filter(lambda r: r in valid_users,
                   self.recipient_list.split("\n")))

        original_user = dataent.session.user

        if recipients:
            for user_id in recipients:
                dataent.set_user(user_id)
                dataent.set_user_lang(user_id)
                msg_for_this_recipient = self.get_msg_html()
                if msg_for_this_recipient:
                    dataent.sendmail(recipients=user_id,
                                     subject=_("{0} Digest").format(
                                         self.frequency),
                                     message=msg_for_this_recipient,
                                     reference_doctype=self.doctype,
                                     reference_name=self.name,
                                     unsubscribe_message=_(
                                         "Unsubscribe from this Email Digest"))

        dataent.set_user(original_user)
        dataent.set_user_lang(original_user)
Exemplo n.º 10
0
def send_email(success, service_name, error_status=None):
	if success:
		if dataent.db.get_value("Dropbox Settings", None, "send_email_for_successful_backup") == '0':
			return

		subject = "Backup Upload Successful"
		message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
		that your backup was successfully uploaded to your %s account. So relax!</p>
		""" % service_name

	else:
		subject = "[Warning] Backup Upload Failed"
		message ="""<h3>Backup Upload Failed</h3><p>Oops, your automated backup to %s
		failed.</p>
		<p>Error message: <br>
		<pre><code>%s</code></pre>
		</p>
		<p>Please contact your system manager for more information.</p>
		""" % (service_name, error_status)

	if not dataent.db:
		dataent.connect()

	recipients = split_emails(dataent.db.get_value("Dropbox Settings", None, "send_notifications_to"))
	dataent.sendmail(recipients=recipients, subject=subject, message=message)
Exemplo n.º 11
0
def send_message(subject="Website Query", message="", sender=""):
	if not message:
		dataent.response["message"] = 'Please write something'
		return

	if not sender:
		dataent.response["message"] = 'Email Address Required'
		return

	# guest method, cap max writes per hour
	if dataent.db.sql("""select count(*) from `tabCommunication`
		where `sent_or_received`="Received"
		and TIMEDIFF(%s, modified) < '01:00:00'""", now())[0][0] > max_communications_per_hour:
		dataent.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
		return

	# send email
	forward_to_email = dataent.db.get_value("Contact Us Settings", None, "forward_to_email")
	if forward_to_email:
		dataent.sendmail(recipients=forward_to_email, sender=sender, content=message, subject=subject)


	# add to to-do ?
	dataent.get_doc(dict(
		doctype = 'Communication',
		sender=sender,
		subject= _('New Message from Website Contact Page'),
		sent_or_received='Received',
		content=message,
		status='Open',
	)).insert(ignore_permissions=True)

	return "okay"
Exemplo n.º 12
0
def _notify(args):
    from dataent.utils import get_fullname, get_url

    args = dataent._dict(args)
    contact = args.contact
    txt = args.txt

    try:
        if not isinstance(contact, list):
            contact = [
                dataent.db.get_value("User", contact, "email") or contact
            ]

        dataent.sendmail(\
         recipients=contact,
         sender= dataent.db.get_value("User", dataent.session.user, "email"),
         subject=_("New message from {0}").format(get_fullname(dataent.session.user)),
         template="new_message",
         args={
          "from": get_fullname(dataent.session.user),
          "message": txt,
          "link": get_url()
         },
         header=[_('New Message'), 'orange'])
    except dataent.OutgoingEmailError:
        pass
Exemplo n.º 13
0
def send_project_update_email_to_users(project):
    doc = dataent.get_doc('Project', project)

    if is_holiday_today(doc.holiday_list) or not doc.users: return

    project_update = dataent.get_doc({
        "doctype":
        "Project Update",
        "project":
        project,
        "sent":
        0,
        "date":
        today(),
        "time":
        nowtime(),
        "naming_series":
        "UPDATE-.project.-.YY.MM.DD.-",
    }).insert()

    subject = "For project %s, update your status" % (project)

    incoming_email_account = dataent.db.get_value(
        'Email Account', dict(enable_incoming=1, default_incoming=1),
        'email_id')

    dataent.sendmail(recipients=get_users_email(doc),
                     message=doc.message,
                     subject=_(subject),
                     reference_doctype=project_update.doctype,
                     reference_name=project_update.name,
                     reply_to=incoming_email_account)
Exemplo n.º 14
0
    def test_sendmail(self):
        dataent.sendmail(sender="*****@*****.**",
                         recipients="*****@*****.**",
                         content="test mail 001",
                         subject="test-mail-001",
                         delayed=False)

        sent_mail = email.message_from_string(
            dataent.safe_decode(dataent.flags.sent_mail))
        self.assertTrue("test-mail-001" in sent_mail.get("Subject"))
Exemplo n.º 15
0
def notify_customers(delivery_trip):
    delivery_trip = dataent.get_doc("Delivery Trip", delivery_trip)

    context = delivery_trip.as_dict()

    if delivery_trip.driver:
        context.update(
            dataent.db.get_value("Driver",
                                 delivery_trip.driver,
                                 "cell_number",
                                 as_dict=1))

    email_recipients = []

    for stop in delivery_trip.delivery_stops:
        contact_info = dataent.db.get_value(
            "Contact",
            stop.contact, ["first_name", "last_name", "email_id"],
            as_dict=1)

        context.update({"items": []})
        if stop.delivery_note:
            items = dataent.get_all("Delivery Note Item",
                                    filters={
                                        "parent": stop.delivery_note,
                                        "docstatus": 1
                                    },
                                    fields=["*"])
            context.update({"items": items})

        if contact_info and contact_info.email_id:
            context.update(stop.as_dict())
            context.update(contact_info)

            dispatch_template_name = dataent.db.get_single_value(
                "Delivery Settings", "dispatch_template")
            dispatch_template = dataent.get_doc("Email Template",
                                                dispatch_template_name)

            dataent.sendmail(recipients=contact_info.email_id,
                             subject=dispatch_template.subject,
                             message=dataent.render_template(
                                 dispatch_template.response, context),
                             attachments=get_attachments(stop))

            stop.db_set("email_sent_to", contact_info.email_id)
            email_recipients.append(contact_info.email_id)

    if email_recipients:
        dataent.msgprint(
            _("Email sent to {0}").format(", ".join(email_recipients)))
        delivery_trip.db_set("email_notification_sent", True)
    else:
        dataent.msgprint(_("No contacts with email IDs found."))
Exemplo n.º 16
0
def backup_files_and_notify_user(user_email=None):
    from dataent.utils.backups import backup
    backup_files = backup(with_files=True)
    get_downloadable_links(backup_files)

    subject = _("File backup is ready")
    dataent.sendmail(recipients=[user_email],
                     subject=subject,
                     template="file_backup_notification",
                     args=backup_files,
                     header=[subject, 'green'])
Exemplo n.º 17
0
    def send_summary(self):
        '''Send summary of all replies. Called at midnight'''
        args = self.get_message_details()
        emails = get_user_emails_from_group(self.daily_work_summary_group)
        dataent.sendmail(recipients=emails,
                         template='daily_work_summary',
                         args=args,
                         subject=_(self.daily_work_summary_group),
                         reference_doctype=self.doctype,
                         reference_name=self.name)

        self.db_set('status', 'Sent')
Exemplo n.º 18
0
def add_to_email_queue(context, email_path):
    "Add an email to the Email Queue"
    site = get_site(context)

    if os.path.isdir(email_path):
        with dataent.init_site(site):
            dataent.connect()
            for email in os.listdir(email_path):
                with open(os.path.join(email_path, email)) as email_data:
                    kwargs = json.load(email_data)
                    kwargs['delayed'] = True
                    dataent.sendmail(**kwargs)
                    dataent.db.commit()
Exemplo n.º 19
0
def email_setup_wizard_exception(traceback, args):
	if not dataent.local.conf.setup_wizard_exception_email:
		return

	pretty_args = prettify_args(args)

	if dataent.local.request:
		user_agent = UserAgent(dataent.local.request.headers.get('User-Agent', ''))

	else:
		user_agent = dataent._dict()

	message = """

#### Traceback

<pre>{traceback}</pre>

---

#### Setup Wizard Arguments

<pre>{args}</pre>

---

#### Request Headers

<pre>{headers}</pre>

---

#### Basic Information

- **Site:** {site}
- **User:** {user}
- **Browser:** {user_agent.platform} {user_agent.browser} version: {user_agent.version} language: {user_agent.language}
- **Browser Languages**: `{accept_languages}`""".format(
		site=dataent.local.site,
		traceback=traceback,
		args="\n".join(pretty_args),
		user=dataent.session.user,
		user_agent=user_agent,
		headers=dataent.local.request.headers,
		accept_languages=", ".join(dataent.local.request.accept_languages.values()))

	dataent.sendmail(recipients=dataent.local.conf.setup_wizard_exception_email,
		sender=dataent.session.user,
		subject="Setup failed: {}".format(dataent.local.site),
		message=message,
		delayed=False)
Exemplo n.º 20
0
    def send_mails(self, dws_group, emails):
        '''Send emails to get daily work summary to all users \
			in selected daily work summary group'''
        incoming_email_account = dataent.db.get_value(
            'Email Account', dict(enable_incoming=1, default_incoming=1),
            'email_id')

        self.db_set('email_sent_to', '\n'.join(emails))
        dataent.sendmail(recipients=emails,
                         message=dws_group.message,
                         subject=dws_group.subject,
                         reference_doctype=self.doctype,
                         reference_name=self.name,
                         reply_to=incoming_email_account)
Exemplo n.º 21
0
def notify_mentions(doc):
    if doc.communication_type != "Comment":
        return

    if doc.reference_doctype and doc.reference_name and doc.content and doc.comment_type == "Comment":
        mentions = extract_mentions(doc.content)

        if not mentions:
            return

        sender_fullname = get_fullname(dataent.session.user)
        title_field = dataent.get_meta(doc.reference_doctype).get_title_field()
        title = doc.reference_name if title_field == "name" else \
         dataent.db.get_value(doc.reference_doctype, doc.reference_name, title_field)

        if title != doc.reference_name:
            parent_doc_label = "{0}: {1} (#{2})".format(
                _(doc.reference_doctype), title, doc.reference_name)
        else:
            parent_doc_label = "{0}: {1}".format(_(doc.reference_doctype),
                                                 doc.reference_name)

        subject = _("{0} mentioned you in a comment").format(sender_fullname)

        recipients = [
            dataent.db.get_value("User", {
                "enabled": 1,
                "name": name,
                "user_type": "System User"
            }, "email") for name in mentions
        ]
        link = get_link_to_form(doc.reference_doctype,
                                doc.reference_name,
                                label=parent_doc_label)

        dataent.sendmail(recipients=recipients,
                         sender=dataent.session.user,
                         subject=subject,
                         template="mentioned_in_comment",
                         args={
                             "body_content":
                             _("{0} mentioned you in a comment in {1}").format(
                                 sender_fullname, link),
                             "comment":
                             doc,
                             "link":
                             link
                         },
                         header=[_('New Mention'), 'orange'])
Exemplo n.º 22
0
def send_email_notification(mr_list):
	""" Notify user about auto creation of indent"""

	email_list = dataent.db.sql_list("""select distinct r.parent
		from `tabHas Role` r, tabUser p
		where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
		and r.role in ('Purchase Manager','Stock Manager')
		and p.name not in ('Administrator', 'All', 'Guest')""")

	msg = dataent.render_template("templates/emails/reorder_item.html", {
		"mr_list": mr_list
	})

	dataent.sendmail(recipients=email_list,
		subject=_('Auto Material Requests Generated'), message = msg)
Exemplo n.º 23
0
def monthly_updates():
    translators = dataent.db.sql_list("""select distinct modified_by from
		`tabTranslated Message`""")

    message = dataent.get_template(
        "/templates/emails/translator_update.md").render({"dataent": dataent})

    # refer unsubscribe against the administrator
    # document for test
    dataent.sendmail(translators,
                     "EPAAS Translator <*****@*****.**>",
                     "Montly Update",
                     message,
                     bulk=True,
                     reference_doctype="User",
                     reference_name="Administrator")
Exemplo n.º 24
0
def send_birthday_reminders():
    """Send Employee birthday reminders if no 'Stop Birthday Reminders' is not set."""
    if int(
            dataent.db.get_single_value("HR Settings",
                                        "stop_birthday_reminders") or 0):
        return

    birthdays = get_employees_who_are_born_today()

    if birthdays:
        employee_list = dataent.get_all('Employee',
                                        fields=['name', 'employee_name'],
                                        filters={
                                            'status': 'Active',
                                            'company': birthdays[0]['company']
                                        })
        employee_emails = get_employee_emails(employee_list)
        birthday_names = [name["employee_name"] for name in birthdays]
        birthday_emails = [
            email["user_id"] or email["personal_email"]
            or email["company_email"] for email in birthdays
        ]

        birthdays.append({
            'company_email': '',
            'employee_name': '',
            'personal_email': '',
            'user_id': ''
        })

        for e in birthdays:
            if e['company_email'] or e['personal_email'] or e['user_id']:
                if len(birthday_names) == 1:
                    continue
                recipients = e['company_email'] or e['personal_email'] or e[
                    'user_id']

            else:
                recipients = list(set(employee_emails) - set(birthday_emails))

            dataent.sendmail(
                recipients=recipients,
                subject=_("Birthday Reminder"),
                message=get_birthday_reminder_message(e, birthday_names),
                header=['Birthday Reminder', 'green'],
            )
Exemplo n.º 25
0
def subscribe(email):
	url = dataent.utils.get_url("/api/method/dataent.email.doctype.newsletter.newsletter.confirm_subscription") +\
		"?" + get_signed_params({"email": email})

	messages = (
		_("Thank you for your interest in subscribing to our updates"),
		_("Please verify your Email Address"),
		url,
		_("Click here to verify")
	)

	content = """
	<p>{0}. {1}.</p>
	<p><a href="{2}">{3}</a></p>
	"""

	dataent.sendmail(email, subject=_("Confirm Your Email"), content=content.format(*messages))
Exemplo n.º 26
0
def send_grant_review_emails(grant_application):
    grant = dataent.get_doc("Grant Application", grant_application)
    url = get_url('grant-application/{0}'.format(grant_application))
    dataent.sendmail(
        recipients=grant.assessment_manager,
        sender=dataent.session.user,
        subject='Grant Application for {0}'.format(grant.applicant_name),
        message='<p> Please Review this grant application</p><br>' + url,
        reference_doctype=grant.doctype,
        reference_name=grant.name)

    grant.status = 'In Progress'
    grant.email_notification_sent = 1
    grant.save()
    dataent.db.commit()

    dataent.msgprint(_("Review Invitation Sent"))
Exemplo n.º 27
0
    def send_welcome_email(self):
        url = get_url("/project/?name={0}".format(self.name))
        messages = (_(
            "You have been invited to collaborate on the project: {0}".format(
                self.name)), url, _("Join"))

        content = """
		<p>{0}.</p>
		<p><a href="{1}">{2}</a></p>
		"""

        for user in self.users:
            if user.welcome_email_sent == 0:
                dataent.sendmail(user.user,
                                 subject=_("Project Collaboration Invitation"),
                                 content=content.format(*messages))
                user.welcome_email_sent = 1
Exemplo n.º 28
0
def notify_admin_access_to_system_manager(login_manager=None):
    if (login_manager and login_manager.user == "Administrator"
            and dataent.local.conf.notify_admin_access_to_system_manager):

        site = '<a href="{0}" target="_blank">{0}</a>'.format(
            dataent.local.request.host_url)
        date_and_time = '<b>{0}</b>'.format(
            format_datetime(now_datetime(), format_string="medium"))
        ip_address = dataent.local.request_ip

        access_message = _(
            'Administrator accessed {0} on {1} via IP Address {2}.').format(
                site, date_and_time, ip_address)

        dataent.sendmail(recipients=get_system_managers(),
                         subject=_("Administrator Logged In"),
                         template="administrator_logged_in",
                         args={'access_message': access_message},
                         header=['Access Notification', 'orange'])
Exemplo n.º 29
0
	def send_auto_reply(self, communication, email):
		"""Send auto reply if set."""
		if self.enable_auto_reply:
			set_incoming_outgoing_accounts(communication)

			if self.send_unsubscribe_message:
				unsubscribe_message = _("Leave this conversation")
			else:
				unsubscribe_message = ""

			dataent.sendmail(recipients = [email.from_email],
				sender = self.email_id,
				reply_to = communication.incoming_email_account,
				subject = _("Re: ") + communication.subject,
				content = render_template(self.auto_reply_message or "", communication.as_dict()) or \
					 dataent.get_template("templates/emails/auto_reply.html").render(communication.as_dict()),
				reference_doctype = communication.reference_doctype,
				reference_name = communication.reference_name,
				in_reply_to = email.mail.get("Message-Id"), # send back the Message-Id as In-Reply-To
				unsubscribe_message = unsubscribe_message)
Exemplo n.º 30
0
def send_email(success, service_name, error_status=None):
	if success:
		if dataent.db.get_value("S3 Backup Settings", None, "send_email_for_successful_backup") == '0':
			return

		subject = "Backup Upload Successful"
		message = """<h3>Backup Uploaded Successfully! </h3><p>Hi there, this is just to inform you
		that your backup was successfully uploaded to your Amazon S3 bucket. So relax!</p> """

	else:
		subject = "[Warning] Backup Upload Failed"
		message = """<h3>Backup Upload Failed! </h3><p>Oops, your automated backup to Amazon S3 failed.
		</p> <p>Error message: %s</p> <p>Please contact your system manager
		for more information.</p>""" % error_status

	if not dataent.db:
		dataent.connect()

	if dataent.db.get_value("S3 Backup Settings", None, "notification_email"):
		recipients = split_emails(dataent.db.get_value("S3 Backup Settings", None, "notification_email"))
		dataent.sendmail(recipients=recipients, subject=subject, message=message)