Log sent message
@param string $recipient Recipient email address
@param string $headers Email headers string
@param string $email Email content
@param string $method Send method
@return void
541285
protected function Log ($recipient, $headers, $email, $method)
    {

        // Set filename

        $filename	= date ('Y-m-d_H-i-s') . '_' . $method . '_' . $recipient . '.txt';

        // Log

        @file_put_contents (EMAIL_LOG_PATH . $filename, $headers . $email);

    }
1275731
protected function _addRecipientAndHeader($headerName, $email, $name)
    {
        $email = $this->_filterEmail($email);
        $name  = $this->_filterName($name);
        // prevent duplicates
        $this->_recipients[$email] = 1;
        $this->_storeHeader($headerName, $this->_formatAddress($email, $name), true);
    }
1020683
public function parseHeaderInfo(Email &$email, $header)
    {

        //map the most useful header info to the email object itself
        $email->all_headers = $header;
        $email->subject = $header->subject;
        $email->to = $header->to[0]->mailbox . '@' . $header->to[0]->host;
        $email->from = $header->from[0]->mailbox . '@' . $header->from[0]->host;
        $email->reply_to = $header->reply_to[0]->mailbox . '@' . $header->reply_to[0]->host;
        $email->sender = $header->sender[0]->mailbox . '@' . $header->sender[0]->host;
        $email->size = $header->Size;
        $email->date = $header->date;
        $email->timestamp = $header->udate;
        $email->message_id = $header->message_id;
        if ($header->Deleted == 'D') {
            $email->deleted = 1;
        }

        //add the entire header in case we want access to custom headers later
        $this->headers = $header;
    }
311917
protected function sendEmailNotification($subject, $message)
    {
        $superUsers = UsersManagerApi::getInstance()->getUsersHavingSuperUserAccess();

        foreach ($superUsers as $superUser) {
            $mail = new Mail();
            $mail->setDefaultFromPiwik();
            $mail->addTo($superUser['email']);
            $mail->setSubject($subject);
            $mail->setWrappedHtmlBody($message);
            $mail->send();
        }
    }
987175
protected function logSend($result, $mailer)
    {
        if ($this->log() === false) {
            return;
        }

        if (!$result) {
            $this->logger->error('Email could not be sent.');
        } else {
            $this->logger->debug(
                sprintf('Email "%s" sent successfully.', $this->subject()),
                $this->to()
            );
        }

        $recipients = array_merge(
            $this->to(),
            $this->cc(),
            $this->bcc()
        );

        foreach ($recipients as $to) {
            $log = $this->logFactory()->create('charcoal/email/email-log');

            $log->setType('email');
            $log->setAction('send');

            $log->setRawResponse($mailer);

            $log->setMessageId($mailer->getLastMessageId());
            $log->setCampaign($this->campaign());

            $log->setSendDate('now');

            $log->setFrom($mailer->From);
            $log->setTo($to);
            $log->setSubject($this->subject());

            $log->save();
        }
    }
688075
public function send($send_headers = false)
	{
		$body = $this->__toString();

		if ($send_headers)
		{
			$this->send_headers();
		}

		if ($this->body != null)
		{
			echo $body;
		}
	}
936751
public function send(Message $message) : void
    {
        $sender = $this->smtp['sender'];
        $recipients = is_array($sender['to']) ? $sender['to'] : [$sender['to']];

        $message->setFrom($sender['email'], $sender['name']);

        foreach ($recipients as $to)
        {
            $message->addTo($to);
        }

        $mailer = new \Nette\Mail\SmtpMailer($this->smtp['config']);
        $mailer->send($message);
    }
726639
function SendmailSend($header, $body) {
    if ($this->Sender != "")
    $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
    else
    $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));

    if(!@$mail = popen($sendmail, "w"))
    {
      $this->SetError($this->Lang("execute") . $this->Sendmail);
      return false;
    }

    fputs($mail, $header);
    fputs($mail, $body);

    $result = pclose($mail) >> 8 & 0xFF;
    if($result != 0)
    {
      $this->SetError($this->Lang("execute") . $this->Sendmail);
      return false;
    }

    return true;
  }
574224
protected function emailOutput(Mailer $mailer, $addresses)
	{
		$mailer->raw(file_get_contents($this->output), function($m) use ($addresses)
		{
			$m->subject($this->getEmailSubject());

			foreach ($addresses as $address)
			{
				$m->to($address);
			}
		});
	}
177288
protected function SmtpSend($header, $body) {
    require_once $this->PluginDir . 'class.smtp.php';
    $bad_rcpt = array();

    if(!$this->SmtpConnect()) {
      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
    }
    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
    if(!$this->smtp->Mail($smtp_from)) {
      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
    }

    // Attempt to send attach all recipients
    foreach($this->to as $to) {
      if (!$this->smtp->Recipient($to[0])) {
        $bad_rcpt[] = $to[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
      }
    }
    foreach($this->cc as $cc) {
      if (!$this->smtp->Recipient($cc[0])) {
        $bad_rcpt[] = $cc[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
      }
    }
    foreach($this->bcc as $bcc) {
      if (!$this->smtp->Recipient($bcc[0])) {
        $bad_rcpt[] = $bcc[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
      }
    }


    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
      $badaddresses = implode(', ', $bad_rcpt);
      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
    }
    if(!$this->smtp->Data($header . $body)) {
      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
    }
    if($this->SMTPKeepAlive == true) {
      $this->smtp->Reset();
    }
    return true;
  }
861104
private function sendContactMail($email, $subject, $message)
    {
        $mailer = oxNew(Email::class);

        if ($mailer->sendContactMail($email, $subject, $message)) {
            $this->_blContactSendStatus = 1;
        } else {
            Registry::getUtilsView()->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
        }
    }
471203
public static void deliverMail (String[] recipients, String sender,
                                    String subject, MimeMessage message)
        throws IOException
    {
        checkCreateSession();
        try {
            message.setFrom(new InternetAddress(sender));
            for (String recipient : recipients) {
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
            }
            if (subject != null) {
                message.setSubject(subject);
            }
            message.saveChanges();
            Address[] recips = message.getAllRecipients();
            if (recips == null || recips.length == 0) {
                log.info("Not sending mail to zero recipients",
                    "subject", subject, "message", message);
                return;
            }
            Transport t = _defaultSession.getTransport(recips[0]);
            try {
                t.addTransportListener(_listener);
                t.connect();
                t.sendMessage(message, recips);

            } finally {
                t.close();
            }

        } catch (Exception e) {
            String errmsg = "Failure sending mail [from=" + sender +
                ", to=" + StringUtil.toString(recipients) +
                ", subject=" + subject + "]";
            IOException ioe = new IOException(errmsg);
            ioe.initCause(e);
            throw ioe;
        }
    }
692662
public function sendMessage($recipients, $sender, $subject, $content)
    {
        $this->client->sendMessage($this->createMessage($recipients, $sender, $subject, $content));
    }
419963
public function send($headers)
    {
        $this->debug->groupCollapsed(__METHOD__);
        // $this->debug->log('headers', $headers);
        $return = false;
        self::normalizeHeaders($headers, $this->cfg['email']['from']);
        if (!empty($headers['Attachments'])) {
            $headers['MIME-Version'] = '1.0';
            if (!empty($headers['Body'])) {
                array_unshift($headers['Attachments'], array('body'=>$headers['Body']));
                if (!empty($headers['Content-Type'])) {
                    $headers['Attachments'][0]['content_type'] = $headers['Content-Type'];
                }
            }
            list($headers['Content-Type'], $headers['Body']) = $this->buildBody($headers['Attachments']);
            unset($headers['Attachments']);
        }
        $this->debugHeaders($headers);
        $headersAddStr = self::buildAdditionalHeadersString($headers);
        $params = array($headers['To'], $headers['Subject'], $headers['Body'], $headersAddStr);
        if (!ini_get('safe_mode')) {
            $params[] = self::buildAdditionalParamsString($headers);
        }
        if ($headers['To']) {
            if ($this->cfg['debugMode']) {
                $this->debug->warn('debugMode: email not sent');
                // don't sent email when debug=true
                $return = true;
                $this->debugResult = $params;
            } else {
                $return = call_user_func_array('mail', $params);
            }
        }
        $this->debug->log('Email was '.(($return)?'':'NOT').' successful');
        $this->debug->groupEnd();
        return $return;
    }
585101
private function sendReply ($reply, array $headers = [])
    {
        if ($this->sent) {
            throw new Exception\AlreadySentException();
        }

        $headers = array_merge(
            [
                'Connection: close',
                'Content-Length: ' . strlen($reply),
            ],
            $headers
        );

        $hasContentType = false;
        foreach ($headers as $headerLine) {
            if (stripos($headerLine, 'Content-Type') !== false) {
                $hasContentType = true;
                break;
            }
        }

        if (!$hasContentType) {
            $headers[] = 'Content-Type: application/xml';
        }
        
        $this->sent = true;
        $this->printReply($reply, $headers);
    }
149763
protected function sendMail($to, $subject, $body, $headers)
    {
        return mail(
            $to,
            $subject,
            $body,
            $headers
        );
    }
477674
protected function sendHeaders(array $headers = [])
    {
        ini_set('expose_php', 0);

        // collect headers that already sent
        foreach (headers_list() as $header) {
            $headerParts = explode(':', $header);
            $headerParts = array_map('trim', $headerParts);
            $headers[ $headerParts[ 0 ] ] = $headerParts[ 1 ];
            header_remove($header[ 0 ]);
        }

        if (count($headers)) {
            $this->headers = array_merge($this->headers, $headers);
        }

        if ($this->statusCode === 204) {
            $this->statusCode = 200;
            $this->reasonPhrase = 'OK';
        }

        $this->sendHeaderStatus($this->statusCode, $this->reasonPhrase, $this->protocol);

        foreach ($this->headers as $name => $value) {
            $this->sendHeader($name, $value);
        }
    }