Utility method to send mail with the `mail` template context.
965787
def send_mail(self, subject, to, template, **template_ctx):
        
        if not self.mail:
            from warnings import warn
            warn('Attempting to send mail without the mail bundle installed! '
                 'Please install it, or fix your configuration.')
            return

        self.mail.send(subject, to, template, **dict(
            **self.security.run_ctx_processor('mail'),
            **template_ctx))
432337
def send_mail(subject, recipient, template, **context):
    

    config = current_app.config
    sender = config["MAIL_SENDER"]
    msg = Message(subject, sender=sender, recipients=[recipient])

    template_name = f"login/email/{template}.txt"
    msg.body = render_template_i18n(template_name, **context)
    # msg.html = render_template('%s/%s.html' % ctx, **context)

    mail = current_app.extensions.get("mail")
    current_app.logger.debug("Sending mail...")
    mail.send(msg)
167196
function Email (template, options) {
	debug('email %s', template);

	options = options || {};

	if (!template) {
		throw new Error('You must provide an email template');
	}

	// init extension and engine
	// options.ext is supported for backwards compatibility with keystone.Email
	this.ext = path.extname(template) || options.ext;
	var engine = options.engine;
	if (!this.ext && !engine) {
		throw new Error('You must provide options.engine or include the extension in your template path');
	} else if (!this.ext && typeof engine === 'function') {
		throw new Error('You must include the extension in your template path when options.engine is a function');
	} else if (!this.ext) {
		this.ext = '.' + engine;
	} else if (!engine) {
		engine = this.ext.substr(1);
	}
	this.engine = getEngine(engine);
	if (typeof this.engine !== 'function') {
		throw new Error('Invalid engine (' + engine + ')');
	}
	// this corrects for if options.ext is passed in without the `.`
	if (this.ext[0] !== '.') {
		this.ext = '.' + this.ext;
	}

	// init template
	this.root = options.root || process.cwd();
	this.template = this.resolve(template);
	if (!isFile(this.template)) {
		throw new Error('Invalid template (' + template + '), could not find file "' + this.template + '"');
	}

	// init transport
	if (options.transport) {
		this.transport = getTransport(options.transport);
	}

	// stash options without consumed properties, this.send() uses it as defaults
	this.options = assign({}, options);
	delete this.options.engine;
	delete this.options.ext;
	delete this.options.root;
	delete this.options.transport;
}
940384
def _send_mail(self, subject, template, enrollment, event):
        """"""

        context = {
            'name': enrollment.name,
            'invitation_url': self.invitation_url,
            'node_name': self.node_name,
            'node_url': self.node_url,
            'uuid': enrollment.uuid
        }

        mail = render(template, context)
        self.log('Mail:', mail, lvl=verbose)
        mime_mail = MIMEText(mail)
        mime_mail['Subject'] = render(subject, context)
        mime_mail['From'] = render(self.config.mail_from, {'hostname': self.hostname})
        mime_mail['To'] = enrollment.email

        self.log('MimeMail:', mime_mail, lvl=verbose)
        if self.config.mail_send is True:
            self.log('Sending mail to', enrollment.email)

            self.fireEvent(task(send_mail_worker, self.config, mime_mail, event), "enrolworkers")
        else:
            self.log('Not sending mail, here it is for debugging info:', mail, pretty=True)
1255169
def send_reservation_maill(self):
        '''
        
        '''
        assert len(self._ids) == 1, 'This is for a single id at a time.'
        ir_model_data = self.env['ir.model.data']
        try:
            template_id = (ir_model_data.get_object_reference
                           ('hotel_reservation',
                            'mail_template_hotel_reservation')[1])
        except ValueError:
            template_id = False
        try:
            compose_form_id = (ir_model_data.get_object_reference
                               ('mail',
                                'email_compose_message_wizard_form')[1])
        except ValueError:
            compose_form_id = False
        ctx = dict()
        ctx.update({
            'default_model': 'hotel.reservation',
            'default_res_id': self._ids[0],
            'default_use_template': bool(template_id),
            'default_template_id': template_id,
            'default_composition_mode': 'comment',
            'force_send': True,
            'mark_so_as_sent': True
        })
        return {
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'mail.compose.message',
            'views': [(compose_form_id, 'form')],
            'view_id': compose_form_id,
            'target': 'new',
            'context': ctx,
            'force_send': True
        }
923535
def send_email(name, ctx_dict, send_to=None, subject=u'Subject', **kwargs):
    

    eft = EmailFromTemplate(name=name)
    eft.subject = subject
    eft.context = ctx_dict
    eft.get_object()
    eft.render_message()
    eft.send_email(send_to=send_to, **kwargs)
136419
function sendMail (template, locals, options, callback) {
  var self = this
  this.render(template, locals, function (err, html, text) {
    if (err) { return callback(err) }

    self.transport.sendMail({
      from: options.from || defaultFrom,
      to: options.to,
      subject: options.subject,
      html: html,
      text: text
    }, callback)
  })
}
159221
def _send(self, server, texts, htmls, dryrun):
        
        import smtplib
        from email.mime.multipart import MIMEMultipart
        from email.mime.text import MIMEText

        # Create message container - the correct MIME type is multipart/alternative.
        emsg = MIMEMultipart('alternative')
        emsg['Subject'] = self.subject
        emsg['From'] = self.sender
        emsg['To'] = ', '.join(self.to)

        # Create the body of the message (a plain-text and an HTML version).
        self.text = '\n'.join(texts) if isinstance(texts, list) else texts
        self.html = """
        <html>
          <head></head>
          <body>
            {}  
          </body>
        </html>
        """.format('\n'.join(htmls) if isinstance(htmls, list) else htmls)

        # Record the MIME types of both parts - text/plain and text/html.
        part1 = MIMEText(self.text, 'plain')
        part2 = MIMEText(self.html, 'html')

        # Attach parts into message container.
        # According to RFC 2046, the last part of a multipart message, in this case
        # the HTML message, is best and preferred.
        emsg.attach(part1)
        emsg.attach(part2)

        # Send the message via the configured SMTP server from ANCLE global configuration.
        if not dryrun:
            s = smtplib.SMTP(server.settings.gateway)
            s.sendmail(self.sender, self.to, emsg.as_string())
            s.quit()

        self.sent = True
163171
def save(self, *args, **kwargs):
        '''
        
        '''
        if self.send_html:
            self.content = get_text_for_html(self.html_content)
        else:
            self.html_content = None

        super(EmailTemplate, self).save(*args, **kwargs)
90847
def email_message(
        self,
        user,
        subject_template,
        body_template,
        sender=None,
        message_class=EmailMessage,
        **kwargs
    ):
        
        if sender:
            try:
                display_name = sender.get_full_name()
            except (AttributeError, TypeError):
                display_name = sender.get_username()
            from_email = "%s <%s>" % (
                display_name, email.utils.parseaddr(settings.DEFAULT_FROM_EMAIL)[1]
            )
            reply_to = "%s <%s>" % (display_name, sender.email)
        else:
            from_email = settings.DEFAULT_FROM_EMAIL
            reply_to = from_email

        headers = {"Reply-To": reply_to}
        kwargs.update({"sender": sender, "user": user})

        subject_template = loader.get_template(subject_template)
        body_template = loader.get_template(body_template)
        subject = subject_template.render(
            kwargs
        ).strip()  # Remove stray newline characters
        body = body_template.render(kwargs)
        return message_class(subject, body, from_email, [user.email], headers=headers)
732433
def send_mass_user_template_mail(subject_template, body_template, users, context):
    
    message_tuples = []
    for user in users:
        context['user'] = user
        subject, body = render_mail_template(subject_template, body_template, context)

        message_tuples.append((subject, body, conf.get('DEFAULT_FROM_EMAIL'), [user.email]))

    if message_tuples:
        send_mass_mail(message_tuples)
488432
def deliver(template, from, to, vars={}, opts={})
      @info = vars
      @info[:company] = from[:name]

      mail(
        from: format_sender(from),
        to: to[:email],
        subject: humanize(template),
        template_path: 'system_notifications',
        template_name: template
      )
    end
74617
def mail_send(from:, from_name:, to:, subject:, body:)
      mail = build_mail(from, from_name, to, subject, body)
      res = client.mail._('send').post(request_body: mail.to_json)
      @last_response = Response.new(res)
    end
796022
def send_msg(template_id, to, reply_to, from, subject, optional = {})

      if optional[:attachments]
        upload(template_id, to, reply_to, from, subject, optional[:merge_fields], optional[:view_online], optional[:click_tracking],
               optional[:suppress_address], optional[:attachments], optional[:headers], optional[:reply_name], optional[:from_address])
      else
        params =  optional ? optional.clone : {}
        params[:template_id] =  template_id
        params[:to] =  to
        params[:reply_to] =  reply_to
        params[:from] =  from
        params[:subject] =  subject

        post @endpoint, params
      end
    end
716441
protected void sendEmail(TaskRuntimeContext context, String outcome)
    throws ObserverException {
        TaskInstance taskInstance = context.getTaskInstance();
        TemplatedEmail templatedEmail = new TemplatedEmail();
        templatedEmail.setFromAddress(getFromAddress());
        templatedEmail.setSubject(getSubject(taskInstance, outcome));
        templatedEmail.setHtml(true);
        templatedEmail.setTemplateAssetVerSpec(getTemplateSpec());
        templatedEmail.setRuntimeContext(context);

        try {
            List<Address> recipients = getRecipientAddresses(outcome);
            List<Address> ccRecipients = getCcRecipientAddresses(outcome);

            if (templatedEmail.getTemplateBody().contains("${taskActionUrl}")) {

                // send individual e-mails
                for (Address recip : recipients) {
                    String cuid = recip.toString().substring(0, recip.toString().indexOf('@'));
                    String userIdentifier = MiniCrypter.encrypt(cuid);
                    taskInstance.setUserIdentifier(userIdentifier);
                    templatedEmail.setRecipients(new Address[]{recip});
                    templatedEmail.setCcRecipients(new Address[0]);
                    try {
                        templatedEmail.sendEmail();
                    }
                    catch (MessagingException ex) {
                        logger.severeException(ex.getMessage(), ex);  // do not rethrow
                    }
                }
                if (ccRecipients != null) {
                    for (Address ccRecip : ccRecipients) {
                        String cuid = ccRecip.toString().substring(0, ccRecip.toString().indexOf('@'));
                        String userIdentifier = MiniCrypter.encrypt(cuid);
                        taskInstance.setUserIdentifier(userIdentifier);
                        templatedEmail.setRecipients(new Address[0]);
                        templatedEmail.setCcRecipients(new Address[]{ccRecip});
                        try {
                            templatedEmail.sendEmail();
                        }
                        catch (MessagingException ex) {
                            logger.severeException(ex.getMessage(), ex);  // do not rethrow
                        }
                    }
                }
            }
            else {
                if ((recipients != null && !recipients.isEmpty()) || (ccRecipients != null && !ccRecipients.isEmpty())) {
                    if (recipients != null)
                        templatedEmail.setRecipients(recipients.toArray(new Address[0]));
                    if (ccRecipients != null)
                        templatedEmail.setCcRecipients(ccRecipients.toArray(new Address[0]));
                    try {
                        templatedEmail.sendEmail();
                    }
                    catch (MessagingException ex) {
                        logger.severeException(ex.getMessage(), ex);  // do not rethrow
                    }
                }
                else {
                    logger.warn("WARNING: No email recipients for task " + context.getTaskInstanceId() + " " + outcome);
                }
            }
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(), ex);
            throw new ObserverException(-1, ex.getMessage(), ex);
        }
    }
259648
def send_mail(subject, text_content, from_email, to, html_content=None, attachments=[], cc=[], bcc=[]):
    
    msg = EmailMultiAlternatives(subject, text_content, from_email, to, cc=cc, bcc=bcc)
    if html_content:
        msg.attach_alternative(html_content, "text/html")
    if attachments:
        for att in attachments:
            if att:

                mimetype = mimetypes.guess_type(att)[0]
                if str(mimetype) in ('image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'):
                    try:
                        with open(att, 'r') as f:
                            email_embed_image(msg, att, f.read())
                    except Exception as e:
                        print(e)
                else:
                    msg.attach_file(att)
    return msg.send()
924017
public function send($sMailTemplate, $sEmailList, $arDefaultEmailData = [], $sEmailDataEventName = null, $bCheckActiveLang = false)
    {
        if (empty($sEmailList) || (!is_string($sEmailList) && !is_array($sEmailList))) {
            return;
        }

        //Get template name
        $this->sMailTemplate = $sMailTemplate;
        if ($bCheckActiveLang) {
            $this->sMailTemplate = $this->addActiveLangSuffix($this->sMailTemplate);
        }

        //Get template data
        $this->arMailData = $this->getMailData($sEmailDataEventName, $arDefaultEmailData);

        //Process email list
        if (is_string($sEmailList)) {
            $arEmailList = explode(',', $sEmailList);
        } else {
            $arEmailList = $sEmailList;
        }

        foreach ($arEmailList as $sEmail) {
            $sEmail = trim($sEmail);

            $this->sendMail($sEmail);
        }
    }