Sends an email
@param string $email
429282
private function SendTo($email)
    {
        $texts = array();
        $subject = Trans('Core.Forms.Form.DefaultSubject');
        $mailer = new PHPMailer();
        $mailer->isHTML(false);
        $mailer->CharSet = 'UTF-8';
        $mailer->setFrom($this->form->GetSendFrom());
        foreach($this->Elements()->GetElements() as $element)
        {
            if ($element instanceof Fields\Submit)
            {
                continue;
            }
            $name = $element->GetName();
            if ($name == 'Subject')
            {
                $subject = $this->Value($name);
            }
            else if ($name == 'ReplyTo')
            {
                $mailer->addReplyTo($this->Value($name));
            }
            $texts[] = $name . ": " . $this->Value($name);
        }
        $message = join("\r\n", $texts);
        $mailer->Subject = $subject;
        $mailer->Body = $message;
        $mailer->addAddress($email);
        $mailer->send();
    }
1212168
public function setEmail($email){
        if(!$this->setModified('email', $email)->isModified()) {
            return $this;
        }
        $this->email = $email;

        return $this;
    }
768377
public function send($first, $last, $email, $message)
    {
        $quote = nl2br($message);

        $name = $first.' '.$last;

        $this->sendMessage($name, $email, $quote);

        $this->sendThanks($first, $email, $quote);
    }
607295
public function setEmail($email)
    {
        $validator = new EmailValidator();
        if ($validator->validate($email)) {
            $this->_email = $email;
        } else {
            $this->_email = false;
        }
    }
1213504
protected function _sendRcpt($email)
    {
        $from = $this->_prepareFromAddress($email);
        $this->_smtpSend($this->_prepareFromCmd(key($from)));

        $emails = $this->_prepareRecipientAddresses($email);
        foreach ($emails as $mail) {
            $this->_smtpSend($this->_prepareRcptCmd($mail));
        }
    }
955170
public function sendEmail($email)
    {
        return Yii::$app->mailer->compose()
            ->setTo($email)
            ->setFrom([$this->email => $this->name])
            ->setSubject($this->subject)
            ->setTextBody($this->body)
            ->send();
    }
207591
public function setEmail($email): User
    {
        if ($this->email !== $email) {
            $this->email = $email;

            DB::table('user')
                ->where('user_id', '=', $this->user_id)
                ->update([
                    'email' => $email,
                ]);
        }

        return $this;
    }
664055
protected function sendEmail($message): void
    {
        $snooze = \is_numeric($this->emailSnooze)
            ? $this->emailSnooze
            : \strtotime($this->emailSnooze) - \time();

        if ($this->email && $this->mailer
            && @\filemtime($this->directory . '/email-sent') + $snooze < \time() // @ file may not exist
            && @\file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable
        ) {
            ($this->mailer)($message, \implode(', ', (array) $this->email));
        }
    }
968204
public function send(\Tx_Oelib_Mail $email)
    {
        if (!$email->hasSender()) {
            throw new \InvalidArgumentException('$email must have a sender set.', 1331318718);
        }
        $this->validateEmailAddress($email->getSender()->getEmailAddress(), 'From:');
        if ($email->getSubject() === '') {
            throw new \InvalidArgumentException('The e-mail subject must not be empty.', 1409410879);
        }
        if (!$email->hasMessage()) {
            throw new \InvalidArgumentException('The e-mail message must not be empty.', 1409410886);
        }
        $recipients = $email->getRecipients();
        if (empty($recipients)) {
            throw new \InvalidArgumentException('The e-mail must have at least one recipient.', 1409410886);
        }
        foreach ($recipients as $recipient) {
            $this->validateEmailAddress($recipient->getEmailAddress(), 'To:');
        }

        /** @var MailMessage $swiftMail */
        $swiftMail = GeneralUtility::makeInstance(MailMessage::class);
        $swiftMail->setSubject($email->getSubject());

        $sender = $email->getSender();
        $swiftMail->setFrom([$sender->getEmailAddress() => $sender->getName()]);
        if ($email->hasReplyTo()) {
            $replyTo = $email->getReplyTo();
            $swiftMail->setReplyTo([$replyTo->getEmailAddress() => $replyTo->getName()]);
        }
        $swiftMail->setCharset('utf-8');

        $returnPath = $email->getReturnPath();
        if ($returnPath !== '') {
            $swiftMail->setReturnPath($returnPath);
        }

        if ($email->hasMessage()) {
            $swiftMail->setBody($this->formatEmailBody($email->getMessage()));
        }
        if ($email->hasHTMLMessage()) {
            $swiftMail->addPart($email->getHTMLMessage(), 'text/html');
        }

        /** @var \Tx_Oelib_Attachment $attachment */
        foreach ($email->getAttachments() as $attachment) {
            if (($attachment->getFileName() !== '') && ($attachment->getContent() === '')) {
                $swiftAttachment =
                    \Swift_Attachment::fromPath($attachment->getFileName(), $attachment->getContentType());
            } else {
                $fileName = $attachment->getFileName() !== '' ? $attachment->getFileName() : null;
                $swiftAttachment = \Swift_Attachment::newInstance(
                    $attachment->getContent(),
                    $fileName,
                    $attachment->getContentType()
                );
            }

            $swiftMail->attach($swiftAttachment);
        }

        foreach ($email->getRecipients() as $recipient) {
            $swiftMail->setTo([$recipient->getEmailAddress() => $recipient->getName()]);
            $this->sendSwiftMail($swiftMail);
        }
    }
1269207
public function send($email = 0)
    {

        if ($email instanceof Email) {
            $this->addEmailToOutbox($email);
        }

        $sent_emails = 0;

        foreach ($this->emails as &$email) {
            
            //all email goes to DEBUG_EMAIL if specified
            if (defined("DEBUG_EMAIL")) {
                $email->debug_info = "\n\nDEBUG MODE: Should be sent to: " . $email->to . " when not in debug mode!";
                $email->debug_info .= "\nDEBUG MODE: Should be sent from: " . $email->from . " when not in debug mode!";

                $email->to = \DEBUG_EMAIL;
                $email->from = \DEBUG_EMAIL;

                if (!empty($email->cc)) {
                    $email->debug_info .= "\nDEBUG MODE: Should be be CCed to: "
                        . implode(", ", $email->cc) . " when not in debug mode!";
                    $email->cc = Array();
                }

                if (!empty($email->bcc)) {
                    $email->debug_info .= "\nDEBUG MODE: Should be be BCCed to: "
                        . implode(", ", $email->bcc) . " when not in debug mode!";
                    $email->bcc = Array();
                }

                $email->body .= $email->debug_info;
                if (!empty($email->body_HTML)) {
                    $email->body_HTML .= nl2br($email->debug_info);
                }
            }
            $email->to = $email->to ? $email->to : null;
            $email->constructMultipartMessage();
            
            //sanitize sender params
            if(preg_match("~<(.*?)>~", $email->from, $match)){
                $sender = $match[1];
            } else {
                $sender = $email->from;
            }
      
            $sender = filter_var($sender, FILTER_SANITIZE_EMAIL);
            $params = sprintf('-f%s', escapeshellcmd($sender));
    
            if (mail($email->to, $email->subject, $email->body, $email->_header_text, $params)) {

                $email->sent = 1;
                $sent_emails++;

                $this->logEmail($email, true);
            } else {
                $this->logEmail($email, false);
            }
        }

        $emails_cnt = count($this->emails);

        $this->emails = Array();

        if ($sent_emails == $emails_cnt) {
            return true;
        } else {
            return false;
        }
    }
1119956
public function send(Email $email) {
		if (!empty($this->_config['queue'])) {
			$this->_config = $this->_config['queue'] + $this->_config;
			$email->setConfig((array)$this->_config['queue'] + ['queue' => []]);
			unset($this->_config['queue']);
		}

		$transport = $this->_config['transport'];
		$email->setTransport($transport);

		/** @var \Queue\Model\Table\QueuedJobsTable $QueuedJobs */
		$QueuedJobs = TableRegistry::getTableLocator()->get('Queue.QueuedJobs');
		$result = $QueuedJobs->createJob('Email', ['transport' => $transport, 'settings' => $email]);
		$result['headers'] = '';
		$result['message'] = '';

		return $result->toArray();
	}
1353547
public function sendRestorePassword(string $email, string $hash): void
	{
		$mail = $this->createMail('restorePassword');

		$mail->link = $this->link('Cms:Sign:restorePassword', [
			'hash' => $hash
		]);

		$mail->setSubject('cms.mailing.restorePassword.subject')
			->addTo($email);

		$mail->send();
	}
245169
public static function email($email)
    {
        $html = self::getInstance()->html;
        $args = func_get_args();
        return call_user_func_array(array($html, __FUNCTION__), $args);
    }
699800
public function set_sender($email)
        {
            $parts = $this->parse_email($email);
            $this->from_user = $parts[0];
            $this->from_domain = $parts[1];
        }
738300
public function send()
    {
        $this->logger->debug(
            'Attempting to send an email',
            $this->to()
        );

        $mail = $this->phpMailer;

        try {
            $this->setSmtpOptions($mail);

            $mail->CharSet = 'UTF-8';

            // Setting reply-to field, if required.
            $replyTo = $this->replyTo();
            if ($replyTo) {
                $replyArr = $this->emailToArray($replyTo);
                $mail->addReplyTo($replyArr['email'], $replyArr['name']);
            }

            // Setting from (sender) field.
            $from = $this->from();
            $fromArr = $this->emailToArray($from);
            $mail->setFrom($fromArr['email'], $fromArr['name']);

            // Setting to (recipients) field(s).
            $to = $this->to();
            foreach ($to as $recipient) {
                $toArr = $this->emailToArray($recipient);
                $mail->addAddress($toArr['email'], $toArr['name']);
            }

            // Setting cc (carbon-copy) field(s).
            $cc = $this->cc();
            foreach ($cc as $ccRecipient) {
                $ccArr = $this->emailToArray($ccRecipient);
                $mail->addCC($ccArr['email'], $ccArr['name']);
            }

            // Setting bcc (black-carbon-copy) field(s).
            $bcc = $this->bcc();
            foreach ($bcc as $bccRecipient) {
                $bccArr = $this->emailToArray($bccRecipient);
                $mail->addBCC($bccArr['email'], $bccArr['name']);
            }

            // Setting attachment(s), if required.
            $attachments = $this->attachments();
            foreach ($attachments as $att) {
                $mail->addAttachment($att);
            }

            $mail->isHTML(true);

            $mail->Subject = $this->subject();
            $mail->Body    = $this->msgHtml();
            $mail->AltBody = $this->msgTxt();

            $ret = $mail->send();

            $this->logSend($ret, $mail);

            return $ret;
        } catch (Exception $e) {
            $this->logger->error(
                sprintf('Error sending email: %s', $e->getMessage())
            );
        }
    }
113450
public function send(Email $email)
    {
        $eol = PHP_EOL;
        if (isset($this->_config['eol'])) {
            $eol = $this->_config['eol'];
        }
        $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
        $to = $headers['To'];
        unset($headers['To']);
        foreach ($headers as $key => $header) {
            $headers[$key] = str_replace(["\r", "\n"], '', $header);
        }
        $headers = $this->_headersToString($headers, $eol);
        $subject = str_replace(["\r", "\n"], '', $email->getSubject());
        $to = str_replace(["\r", "\n"], '', $to);

        $message = implode($eol, $email->message());

        $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
        $this->_mail($to, $subject, $message, $headers, $params);

        $headers .= $eol . 'To: ' . $to;
        $headers .= $eol . 'Subject: ' . $subject;

        return ['headers' => $headers, 'message' => $message];
    }
323079
public function setEmail(string $email = null) : CNabuDataObject
    {
        parent::setEmail($email);
        return parent::setEmailHash(is_string($email) ? self::encodeEmail($email) : null);
    }