Send an email with a single notification.

@param string $body_text
The text to send to the target user.
@param string $langcode
The langcode of the target user.
@param \Drupal\user\Entity\User $target
The target account to send the email to.
183079
protected function sendEmail($body_text, $langcode, User $target) {
    // Translating frequency instance in the language of the user.
    // @codingStandardsIgnoreStart
    $frequency_translated = t($this->getName()->getUntranslatedString(), [], ['langcode' => $langcode]);
    // @codingStandardsIgnoreEnd

    // Construct the render array.
    $notification = [
      '#theme' => 'directmail',
      '#notification' => $body_text,
      '#notification_settings' => t('Based on your @settings, the notification above is sent to you <strong>:frequency</strong>', [
        '@settings' => Link::fromTextAndUrl(t('email notification settings', [], ['langcode' => $langcode]), Url::fromRoute('entity.user.edit_form', ['user' => $target->id()])->setAbsolute())->toString(),
        ':frequency' => $frequency_translated,
      ],
      ['langcode' => $langcode]),
    ];

    $params['body'] = \Drupal::service('renderer')->renderRoot($notification);

    // Send the email.
    $mail_manager = \Drupal::service('plugin.manager.mail');
    $mail_manager->mail(
      'activity_send_email',
      'activity_send_email',
      $target->getEmail(),
      $langcode,
      $params,
      NULL,
      TRUE
    );
  }
1100753
public function create_message($userName, $subject, $textBody, $action = null, $pmId = null)
    {
        try {
            $manager = $this->container->get('symbb.extension.tapatalk.manager.user');
            return $manager->createMessage($userName, $subject, $textBody, $action, $pmId);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc);
        }
    }
288482
private function sendEmail($to = '', $subject = '', $messageText = '')
    {
        $transport = $this->getServiceLocator()->get('mail.transport');
        $message = new Message();
            
        $message->addTo($to)
                ->addFrom($this->getOptions()->getSenderEmailAdress())
                ->setSubject($subject)
                ->setBody($messageText);

        $transport->send($message);
    }
992571
@Override
    public void sendEmail(String subject, String body) {
        if (ArrayUtils.isEmpty(this.recipientEmailAddresses)) {
            log.warn("No recipients configured - no one to notify: ignoring...");
            return;
        }

        SendEmailRequest email = new SendEmailRequest();
        try {
            Destination destination = new Destination();
            destination.setToAddresses(Arrays.asList(this.recipientEmailAddresses));
            email.setDestination(destination);
            email.setSource(System.getProperty("notification.sender", "no-sender-specified"));
            Message message = new Message(new Content(subject), new Body(new Content(body)));
            email.setMessage(message);
            client.sendEmail(email);
            log.info("email sent: {}", email);
        } catch (Exception e) {
            log.error("failed to send " + email + ": " + e.getMessage(), e);
        }

    }
519083
public function createMessage($subject = null, $body = null, $contentType = null, $charset = null)
    {
        $message = Swift_Message::newInstance($subject, $body, $contentType, $charset);

        if(null !== $this->fromEmail) {
            
            if(null === $this->fromName) {
                $message->setFrom($this->fromEmail);
            } else {
                $message->setFrom($this->fromEmail, $this->fromName);
            }
            
        }

        return $message;
    }
826669
public function message($to, $body, $type = 'chat', $subject = null, $payload = null)
    {
        if ($type === null) {
            $type = 'chat';
        }

        $to = htmlspecialchars($to);
        $body = htmlspecialchars($body);
        $subject = htmlspecialchars($subject);

        $out = '<message from="' . $this->fulljid . '" to="' . $to . '" type="' . $type . '">';
        if ($subject) {
            $out .= '<subject>' . $subject . '</subject>';
        }
        $out .= '<body>' . $body . '</body>';
        if ($payload) {
            $out .= $payload;
        }
        $out .= "</message>";

        $this->sendXML($out);
    }
546281
public function sendMessage($recipients, $sender, $subject, $templateName, array $context = array())
    {
        $this->client->sendMessage($this->createMessage(
            $recipients,
            $sender,
            $subject,
            $this->render($templateName, $context)
        ));
    }
814603
private function sendEmail(UserInterface $user, \Swift_Mailer $mailer, $subject, $body, $templateId)
    {
        if (\is_array($body)) {
            $body['email'] = $user->getEmail();
            $body['fullname'] = $user->getProfile()->getFullName();
        } else {
            $body = [
                'email' => $user->getEmail(),
                'fullname' => $user->getProfile()->getFullName(),
                'content' => $body,
            ];
        }

        // Create Message
        $message = (new PdSwiftMessage())
            ->setTemplateId($templateId)
            ->setFrom($this->getParameter('pd_user.mail_sender_address'), $this->getParameter('pd_user.mail_sender_name'))
            ->setTo($user->getEmail())
            ->setSubject($subject)
            ->setBody(serialize($body), 'text/html');

        return (bool)$mailer->send($message);
    }
215731
public function sendByMail($to, $subject, $body, $cc = null)
    {
        $this->setPostFields($body);

        $this->performRequest(rawurlencode($this->getRecordID()).'/odeslani-dokladu?to='.$to.'&subject='.urlencode($subject).'&cc='.$cc
            , 'PUT', 'xml');

        return $this->lastResponseCode == 200;
    }
473476
public function setTextMessage(array $to,
                                   string $subject,
                                   string $body,
                                   array $attachment = null,
                                   array $cc = null,
                                   array $bcc = EMAIL_BCC): void
    {
        $this->email->setFrom($this->from);
        foreach ($to as $value) {
            $this->email->addTo($value);
        }
        if ($cc != null) {
            foreach ($cc as $value) {
                $this->email->addCc($value);
            }
        }
        if ($bcc != null) {
            foreach ($bcc as $value) {
                $this->email->addBcc($value);
            }
        }
        if ($attachment != null) {
            foreach ($attachment as $file) {
                $this->email->addAttachment($file);
            }
        }
        $this->email->setSubject($subject);
        $this->email->setBody($body);
    }
207817
public function createMessage($userName, $subject, $textBody, $action, $pmId)
    {

        $this->debug('createMessage');
        $receivers = array();
        $success = true;
        $error = "";

        if ($action == 1) {
            $oldPm = $this->messageManager->find($pmId);
            $userName[] = $oldPm->getSender()->getUsername();
            $userName = array_unique($userName);
        } else if ($action == 2) {
            $oldPm = $this->messageManager->find($pmId);
            $textBody .= "[quote]" . $oldPm->getMessage() . "[/quote]";
        }

        foreach ($userName as $currUserName) {
            $user = $this->userManager->findByUsername($currUserName);
            if ($user) {
                $receivers[$user->getId()] = $user;
            } else {
                $success = false;
                $error = "User not found";
                break;
            }
        }

        $id = 0;

        if ($success) {
            $errors = array();
            $this->debug("Tapatalk: sendMessage");
            $message = $this->messageManager->sendMessage($subject, $textBody, $receivers, $errors);

            if (!empty($errors)) {
                $error = implode(', ', $errors);
                $success = false;
            } else {
                $id = $message->getId();
            }
        }

        $result['result'] = new \Zend\XmlRpc\Value\Boolean($success);
        if (!empty($error)) {
            $result['result_text'] = new \Zend\XmlRpc\Value\Base64($error);
        }
        $result['msg_id'] = new \Zend\XmlRpc\Value\String($id);

        $response = $this->getResponse($result, 'struct');

        return $response;
    }
488024
function sendTextMessage(recipientId, textToSend, token) {
      textMessageData = {
        text:textToSend
      }
      request({
        url: FB_MSG_URL,
        qs: {access_token:token},
        method: 'POST',
        json: {
          recipient: {id:recipientId},
          message: textMessageData,
        }
      }, function(error, response, body) {
        if (error) {
          node.log('Error sending text message: ', error);
        } else if (response.body.error) {
          node.log('Error: ', response.body.error);
        }
      });
    }
874092
public function sendEmailValidationEmail(
        Garp_Db_Table_Row $user, $code, $updateOrInsert = 'insert'
    ) {
        $authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');

        // Render the email message
        $activationUrl = '/g/auth/validateemail/c/' . $code . '/e/' . md5($user->email) . '/';

        if (!empty($authVars['email_partial'])) {
            $view = Zend_Registry::get('application')->getBootstrap()
                ->getResource('view');

            $emailMessage = $view->partial(
                $authVars['email_partial'], 'default', array(
                'user' => $user,
                'activationUrl' => $activationUrl,
                'updateOrInsert' => $updateOrInsert
                )
            );
            $messageParam = 'htmlMessage';
        } else {
            $snippetId = 'validate email ';
            $snippetId .= $updateOrInsert == 'insert' ? 'new user' : 'existing user';
            $snippetId .= ' email';
            $emailMessage = __($snippetId);
            $emailMessage = Garp_Util_String::interpolate(
                $emailMessage, array(
                'USERNAME' => (string)new Garp_Util_FullName($user),
                'ACTIVATION_URL' => (string)new Garp_Util_FullUrl($activationUrl)
                )
            );
            $messageParam = 'message';
        }

        $mailer = new Garp_Mailer();
        return $mailer->send(
            array(
            'to' => $user->email,
            'subject' => __($authVars['email_subject']),
            $messageParam => $emailMessage
            )
        );
    }
942485
public function register(UserInterface $user, string $code)
    {
        $params = [
            'user' => $user,
            'code' => $code
        ];

        $this->send(self::SUBJECT_KEY_REGISTER, $user, $params);
    }
729906
protected function _sendTextBody($textBody)
    {
        $this->_writeLine('Content-Type: text/plain; charset=utf-8');
        $this->_writeLine('Content-Length: ' . strlen($textBody));
        $this->_writeLine('Content-Transfer-Encoding: base64');
        $this->_writeLine();
        $this->_writeLine(chunk_split(base64_encode($textBody), 983));

        return $this;
    }
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)
1178698
public static function sendGenericEmail($email, $subject, $bodyHtml, $bodyHtmlAlt = '')
    {
        $mail = self::getNewMailer($email);
        $mail->WordWrap = 50; // Set word wrap to 50 characters
        $mail->isHTML(true); // Set email format to HTML
        $mail->Subject = $subject;
        $mail->Body = $bodyHtml;
        $mail->AltBody = $bodyHtmlAlt;
        return $mail->send();
    }