Send a test e-mail.
482627
private function checkMail()
    {
        $this->configureMail();

        try {
            $this->sendMail();

            $result = $this->makeHealthyResult();
        } catch (\Exception $exception) {
            report($exception);

            $result = $this->makeResultFromException($exception);
        }

        $this->restoreMailConfiguration();

        return $result;
    }
409859
def set_email(self, email, _vars=None, lists=None, templates=None, verified=0, optout=None, send=None, send_vars=None):
        
        _vars = _vars or {}
        lists = lists or []
        templates = templates or []
        send_vars = send_vars or []
        data = {'email': email,
                'vars':  _vars.copy(),
                'lists': lists,
                'templates': templates,
                'verified': int(verified)}
        if optout is not None:
            data['optout'] = optout
        if send is not None:
            data['send'] = send
        if send_vars:
            data['send_vars'] = send_vars
        return self.api_post('email', data)
461812
public function send(): void
	{
		/**
		 * Template variables..
		 */
		$this->template->mailData = $this->mailData;

		/**
		 * Stick to convention that Email:
		 * 		/FooMail.php	
		 * 
		 * will have template with path of:
		 * 		/templates/FooMail.latte
		 */
		$mailClassReflection = new \ReflectionClass($this);
		$templateName = $mailClassReflection->getShortName();

		$this->template->setFile(sprintf(
			'%s/templates/%s.latte',
			dirname($mailClassReflection->getFilename()),
			$templateName
		));

		/**
		 * Set body/html body
		 */
		if (version_compare(Engine::VERSION, '2.4.0', '>=')) {
			$this->template->getLatte()->addProvider('uiControl', $this->linkGenerator);
		} else {
			$this->template->_control = $this->linkGenerator;
		}

		$this->message->setHtmlBody((string) $this->template, $this->mailImagesBasePath);

		/**
		 * In case mail sending in on, send message
		 */
		if ($this->config === MailingExtension::CONFIG_BOTH || $this->config === MailingExtension::CONFIG_SEND) {
			$this->mailer->send($this->message);
		}

		/**
		 * In case mail logging is turned on, log message
		 */
		if ($this->config === MailingExtension::CONFIG_LOG || $this->config === MailingExtension::CONFIG_BOTH) {
			$this->logger->log($templateName, $this->message);
		}
	}
1070533
public function sample_basic()
   {
      $data = '<h2>Sample Basic</h2>
               <hr>
               <p>This is a simple basic mail message in <strong>HTML</strong> string format</p>
               <p>Lorem ipsum dolor sit amharum<br /> quod deserunt id dolores.</p>';

      $mail = new Mail();
      $mail->setMailBody($data);
      $mail->sendMail('Test Sample Basic');
      exit('Message Sent!');
   }
104137
def sendmail_proxy(subject, email, template, **context):
    """"""
    sendmail.delay(subject.value, email, template, **context)
639533
public static void main(final String[] args) throws EmailException, IOException {
		final MailInfo info = new MailInfo();
		final Attachment attachment = new Attachment();
		attachment.setData(new FileInputStream("c:/app1-base-jo.sql"));
		attachment.setMimeType("text/html");
		attachment.setDescription("Test Attachment");
		attachment.setName("app1-base-jo.sql");
		info.setHost("mail.hotpop.com");
		info.setTo("jamilshreet@yahoo.com");
		info.setFrom("jamil.shreet@gmail.com");
		info.setSubject("Test for Commons");
		info.setMsg("Hi Jamil how are you this is a test for attachment file");
		info.addAttachment(attachment);
		MailSender sender=new MailSender();
		sender.send(info);
		System.out.println("Done");

	}
1019681
def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """"""
    if not settings.ADMINS:
        return
    mail = EmailMultiAlternatives('%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject),
                                  message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
                                  connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
979593
public function send()
    {
        $blError = true;

        // error
        if (($sOxid = $this->getEditObjectId())) {
            $oPricealarm = oxNew(\OxidEsales\Eshop\Application\Model\PriceAlarm::class);
            $oPricealarm->load($sOxid);

            $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");
            $sMailBody = isset($aParams['oxpricealarm__oxlongdesc']) ? stripslashes($aParams['oxpricealarm__oxlongdesc']) : '';
            if ($sMailBody) {
                $sMailBody = \OxidEsales\Eshop\Core\Registry::getUtilsView()->parseThroughSmarty($sMailBody, $oPricealarm->getId());
            }

            $sRecipient = $oPricealarm->oxpricealarm__oxemail->value;

            $oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
            $blSuccess = (int) $oEmail->sendPricealarmToCustomer($sRecipient, $oPricealarm, $sMailBody);

            // setting result message
            if ($blSuccess) {
                $oPricealarm->oxpricealarm__oxsended->setValue(date("Y-m-d H:i:s"));
                $oPricealarm->save();
                $blError = false;
            }
        }

        if (!$blError) {
            $this->_aViewData["mail_succ"] = 1;
        } else {
            $this->_aViewData["mail_err"] = 1;
        }
    }
358727
protected function sendEmail(): void
    {
        if (!$this->emailing) {
            $mail = $this->getEmail();

            try {
                $this->emailing = true;
                $mail->send();
                $this->messages = [];
                $this->emailing = false;
            } catch (Mail\Exception $e) {
                Log::alert('Can not send log message(s) with e-mail logger', $e);
            }
        }
    }
501586
public function email(): void
    {
        $oInput     = Factory::service('Input');
        $oUserModel = Factory::model('User', 'nails/module-auth');
        $action     = $oInput->post('action');
        $sEmail     = trim($oInput->post('email'));
        $iId        = (int) $oInput->post('id') ?: null;

        switch ($action) {

            case 'add':
                $bIsPrimary  = (bool) $oInput->post('isPrimary');
                $bIsVerified = (bool) $oInput->post('isVerified');

                if ($oUserModel->emailAdd($sEmail, $iId, $bIsPrimary, $bIsVerified)) {
                    $sStatus  = 'success';
                    $sMessage = '"' . $sEmail . '" was added successfully. ';
                } else {
                    $sStatus  = 'error';
                    $sMessage = 'Failed to add email. ';
                    $sMessage .= $oUserModel->lastError();
                }
                break;

            case 'delete':
                if ($oUserModel->emailDelete($sEmail, $iId)) {
                    $sStatus  = 'success';
                    $sMessage = '"' . $sEmail . '" was deleted successfully. ';
                } else {
                    $sStatus  = 'error';
                    $sMessage = 'Failed to delete email "' . $sEmail . '". ';
                    $sMessage .= $oUserModel->lastError();
                }
                break;

            case 'makePrimary':
                if ($oUserModel->emailMakePrimary($sEmail, $iId)) {
                    $sStatus  = 'success';
                    $sMessage = '"' . $sEmail . '" was set as the primary email.';
                } else {
                    $sStatus  = 'error';
                    $sMessage = 'Failed to mark "' . $sEmail . '" as the primary address. ';
                    $sMessage .= $oUserModel->lastError();
                }
                break;

            case 'verify':
                //  Get the code for this email
                $aUserEmails = $oUserModel->getEmailsForUser($iId);
                $sCode       = '';

                foreach ($aUserEmails as $oUserEmail) {
                    if ($oUserEmail->email == $sEmail) {
                        $sCode = $oUserEmail->code;
                    }
                }

                if (!empty($sCode) && $oUserModel->emailVerify($iId, $sCode)) {
                    $sStatus  = 'success';
                    $sMessage = '"' . $sEmail . '" was verified successfully.';
                } elseif (empty($sCode)) {
                    $sStatus  = 'error';
                    $sMessage = 'Failed to mark "' . $sEmail . '" as verified. ';
                    $sMessage .= 'Could not determine email\'s security code.';
                } else {
                    $sStatus  = 'error';
                    $sMessage = 'Failed to mark "' . $sEmail . '" as verified. ';
                    $sMessage .= $oUserModel->lastError();
                }
                break;

            default:
                $sStatus  = 'error';
                $sMessage = 'Unknown action: "' . $action . '"';
                break;
        }

        $oSession = Factory::service('Session', 'nails/module-auth');
        $oSession->setFlashData($sStatus, $sMessage);
        redirect($oInput->post('return'));
    }
102043
def send_mail(template, to, **kwargs):
    

    def cb():
        return mail.send(to=to, template=template, **kwargs)

    return signals.send_mail(cb, data={"to": to, "template": template, "kwargs": kwargs})
1361555
def send_messages(self, email_messages):
        """"""
        if not email_messages:
            return
        with self._lock:
            try:
                stream_created = self.open()
                for message in email_messages:
                    if six.PY3:
                        self.write_message(message)
                    else:
                        self.write_message(message)
                    self.stream.flush()
                if stream_created:
                    self.close()
            except:
                if not self.fail_silently:
                    raise
        return len(email_messages)
31958
def send_ready_for_review(build_id, release_name, release_number):
    """"""
    build = models.Build.query.get(build_id)

    if not build.send_email:
        logging.debug(
            'Not sending ready for review email because build does not have '
            'email enabled. build_id=%r', build.id)
        return

    ops = operations.BuildOps(build_id)
    release, run_list, stats_dict, _ = ops.get_release(
        release_name, release_number)

    if not run_list:
        logging.debug(
            'Not sending ready for review email because there are '
            ' no runs. build_id=%r, release_name=%r, release_number=%d',
            build.id, release.name, release.number)
        return

    title = '%s: %s - Ready for review' % (build.name, release.name)

    email_body = render_template(
        'email_ready_for_review.html',
        build=build,
        release=release,
        run_list=run_list,
        stats_dict=stats_dict)

    recipients = []
    if build.email_alias:
        recipients.append(build.email_alias)
    else:
        for user in build.owners:
            recipients.append(user.email_address)

    if not recipients:
        logging.debug(
            'Not sending ready for review email because there are no '
            'recipients. build_id=%r, release_name=%r, release_number=%d',
            build.id, release.name, release.number)
        return

    message = Message(title, recipients=recipients)
    message.html = email_body

    logging.info('Sending ready for review email for build_id=%r, '
                 'release_name=%r, release_number=%d to %r',
                 build.id, release.name, release.number, recipients)

    return render_or_send(send_ready_for_review, message)
216953
def send(mail, server='localhost'):
    
    sender = mail.get_sender()
    rcpt = mail.get_receipients()
    session = smtplib.SMTP(server)
    message = MIMEMultipart()
    message['Subject'] = mail.get_subject()
    message['From'] = mail.get_sender()
    message['To'] = ', '.join(mail.get_to())
    message['Cc'] = ', '.join(mail.get_cc())
    message.preamble = 'Your mail client is not MIME aware.'

    body = MIMEText(mail.get_body().encode("utf-8"), "plain", "utf-8")
    body.add_header('Content-Disposition', 'inline')
    message.attach(body)

    for filename in mail.get_attachments():
        message.attach(_get_mime_object(filename))

    session.sendmail(sender, rcpt, message.as_string())
350256
public function send()
    {
        $mimeMessage = $this->createMimeMessage();
        $this->message = $mimeMessage;
        $this->preparingSend();
        imap_mail(
            $this->properties->to,
            $this->properties->subject,
            $this->properties->message,
            $this->properties->additional_headers,
            $this->properties->cc,
            $this->properties->bcc,
            $this->properties->rpath
        );
    }
295315
def deliver(self, message):
        """"""
        
        config = self.config
        success = config.success
        failure = config.failure
        exhaustion = config.exhaustion
        
        if getattr(message, 'die', False):
            1/0
        
        if failure:
            chance = random.randint(0,100001) / 100000.0
            if chance < failure:
                raise TransportFailedException("Mock failure.")
        
        if exhaustion:
            chance = random.randint(0,100001) / 100000.0
            if chance < exhaustion:
                raise TransportExhaustedException("Mock exhaustion.")
        
        if success == 1.0:
            return True
        
        chance = random.randint(0,100001) / 100000.0
        if chance <= success:
            return True
        
        return False
1037075
function sendVerificationEmail (req, res, next) {
  // skip if we don't need to send the email
  if (!req.sendVerificationEmail) {
    next()

  // send the email
  } else {
    var user = req.user

    var ttl = (settings.emailVerification &&
      settings.emailVerification.tokenTTL) ||
      (3600 * 24 * 7)

    OneTimeToken.issue({
      ttl: ttl,
      sub: user._id,
      use: 'emailVerification'
    }, function (err, token) {
      if (err) { return next(err) }

      var params = {
        token: token._id
      }

      ;[ 'redirect_uri', 'client_id', 'response_type', 'scope' ]
        .forEach(function (key) {
          var value = req.connectParams[key]
          if (value) {
            params[key] = value
          }
        })

      // build email link
      var verifyURL = url.parse(settings.issuer)
      verifyURL.pathname = 'email/verify'
      verifyURL.query = params

      // email template data
      var locals = {
        email: user.email,
        name: {
          first: user.givenName,
          last: user.familyName
        },
        verifyURL: url.format(verifyURL)
      }

      // Send verification email
      mailer.getMailer().sendMail('verifyEmail', locals, {
        to: user.email,
        subject: 'Verify your e-mail address'
      }, function (err, responseStatus) {
        if (err) { }
        // TODO: REQUIRES REFACTOR TO MAIL QUEUE
        next()
      })
    })
  }
}