Send message via imap_mail.

@return void
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
        );
    }
74722
public function send()
    {
        $args = func_get_args();
        if (count($args) > 1) {
            $message = call_user_func_array('sprintf', $args);
        } else {
            $message = $args[0];
        }
        $this->response->send($message);
    }
977654
public function send() {
		if (!$this->validate($errors)) {
			throw new \Exception('Cannot send email, Mail not validated. Errored fields: ' . implode(', ', $errors));
		}

		if (Config::$archive_mailbox !== null) {
			$this->add_bcc(Config::$archive_mailbox);
		}

		$template = new \Skeleton\Template\Template();
		if ($this->translation !== null) {
			$template->set_translation($this->translation);
		}

		if (count($this->template_directories) == 0) {
			$this->add_template_directory(Config::$email_directory . '/template/');
		}

		foreach ($this->template_directories as $template_directory) {
			$template->add_template_directory($template_directory['directory'], $template_directory['namespace']);
		}

		foreach ($this->assigns as $key => $value) {
			$template->assign($key, $value);
		}

		$transport = \Swift_MailTransport::newInstance();
		$mailer = \Swift_Mailer::newInstance($transport);
		$message = \Swift_Message::newInstance()
			->setBody($template->render( $this->type . '/html.twig'), 'text/html')
			->addPart($template->render( $this->type . '/text.twig' ), 'text/plain')
			->setSubject(trim($template->render( $this->type . '/subject.twig' )))
		;

		// Add header
		if (isset(\Skeleton\Email\Config::$email_type_header) AND \Skeleton\Email\Config::$email_type_header !== null) {
			$headers = $message->getHeaders();
			$headers->addTextHeader(\Skeleton\Email\Config::$email_type_header, $this->type);
		}

		// Set sender
		if (isset($this->sender['name'])) {
			$message->setFrom([$this->sender['email'] => $this->sender['name']]);
		} else {
			$message->setFrom($this->sender['email']);
		}

		// Set reply to
		foreach ($this->reply_to as $reply_to) {
			if (isset($reply_to['name'])) {
				$message->setReplyTo([ $reply_to['email'] => $reply_to['name'] ]);
			} else {
				$message->setReplyTo($reply_to['email']);
			}
		}

		$this->add_html_images($message);
		$this->attach_files($message);

		// Remove duplicate recipients, in order of importance
		$types = ['bcc', 'cc', 'to'];
		foreach ($types as $type) {
			array_shift($types);

			if (count($types) === 0) {
				continue;
			}

			if (isset($this->recipients[$type])) {
				foreach ($this->recipients[$type] as $key => $recipient) {
					if ($this->addressee_exists($recipient['email'], $types)) {
						unset($this->recipients[$type][$key]);
					}
				}
			}
		}

		// Add recipients
		foreach ($this->recipients as $type => $recipients) {
			$addresses = [];

			foreach ($recipients as $recipient) {
				if (!empty(\Skeleton\Email\Config::$redirect_all_mailbox)) {
					$recipient['email'] = \Skeleton\Email\Config::$redirect_all_mailbox;
				}

				if (!\Swift_Validate::email($recipient['email'])) {
					if (Config::$strict_address_validation !== false) {
						throw new Exception\Validation('Invalid e-mail address: ' . $recipient['email']);
					} else {
						continue;
					}
				}

				if ($recipient['name'] != '') {
					$addresses[$recipient['email']] = $recipient['name'];
				} else {
					$addresses[] = $recipient['email'];
				}
			}

			$set_to = 'set' . ucfirst($type);

			try {
				call_user_func([$message, $set_to], $addresses);
			} catch (\Swift_RfcComplianceException $e) {
				if (Config::$strict_address_validation !== false) {
					throw new Exception\Validation($e->getMessage());
				}
			}
		}

		// If we have no recipients in the message, and strict validation is
		// disabled, and we do have recipients locally, fail silently. This means
		// all recipients set by the user were invalid.
		if (
			(count($message->getTo()) < 1 and count($message->getCc()) < 1 and count($message->getBcc()) < 1) and
			(isset($this->recipients) and count($this->recipients) > 0) and
			Config::$strict_address_validation === false
		) {
			return;
		}

		$mailer->send($message);
		unset($template);
	}
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;
        }
    }
817485
protected function _sendMail()
    {
        $file = $this->_path . DIRECTORY_SEPARATOR . call_user_func($this->_callback, $this);

        if (!is_writable(dirname($file))) {
            // require_once 'Zend/Mail/Transport/Exception.php';
            throw new Zend_Mail_Transport_Exception(sprintf(
                'Target directory "%s" does not exist or is not writable',
                dirname($file)
            ));
        }

        $email = $this->header . $this->EOL . $this->body;

        if (!file_put_contents($file, $email)) {
            // require_once 'Zend/Mail/Transport/Exception.php';
            throw new Zend_Mail_Transport_Exception('Unable to send mail');
        }
    }
299092
public function send()
    {
        if (!$this->mailSender) {
            throw new \Parable\Mail\Exception('No mail sender implementation set.');
        }

        // Check the basics
        if (count($this->addresses['to']) === 0) {
            throw new \Parable\Mail\Exception('No to addresses provided.');
        }
        if (empty($this->subject)) {
            throw new \Parable\Mail\Exception('No subject provided.');
        }
        if (empty($this->body)) {
            throw new \Parable\Mail\Exception('No body provided.');
        }

        // Handle the to, cc and bcc addresses
        $to  = $this->getAddressesForType('to');
        $cc  = $this->getAddressesForType('cc');
        $bcc = $this->getAddressesForType('bcc');

        if (!empty($cc)) {
            $this->addHeader("Cc: {$cc}");
        }
        if (!empty($bcc)) {
            $this->addHeader("Bcc: {$bcc}");
        }

        // Handle from
        $from = $this->getAddressesForType('from');
        $this->addHeader("From: {$from}");

        $headers = array_merge($this->requiredHeaders, $this->headers);
        $headers = implode("\r\n", $headers);

        return $this->getMailSender()->send($to, $this->subject, $this->body, $headers);
    }
1005919
public function send(?string $message = null, ?string $subject = null)
  {
    if ($message != null) {
      $this->body = $message;
    }

    if ($subject != null) {
      $this->subject = $subject;
    }

    if ($this->viewLocation != null || $this->viewLocation !== '') {
      $this->render($this->viewLocation, $this->viewArgs);
    }

    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = $this->connection['encryption'];
    $mail->SMTPKeepAlive = true;
    $mail->Host = $this->connection['host'];
    $mail->Port = $this->connection['port'];
    $mail->IsHTML(true);
    $mail->Username = $this->connection['username'];
    $mail->Password = $this->connection['password'];

    $mail->SetFrom($this->connection['from']['address'], $this->connection['from']['name']);

    $mail->Subject = $this->subject;
    $mail->Body = $this->outputdata == null ? $this->body : $this->outputdata;

    if ($this->replyTo != null) {
      $mail->addReplyTo($this->replyTo['email'], $this->replyTo['name']);
    }

    if ($this->to != null) {
      foreach($this->to as $email) {
        $mail->AddAddress($email['email'], $email['name']);
      }
    }

    if ($this->bcc != null) {
      foreach($this->bcc as $email) {
        $mail->addBCC($email['email'], $email['name']);
      }
    }

    if ($this->cc != null) {
      foreach($this->cc as $email) {
        $mail->addCC($email['email'], $email['name']);
      }
    }

    if ($this->attachment != null) {
      foreach($this->attachment as $attachment) {
        $mail->addAttachment($attachment['file'], $attachment['name']);
      }
    }

    if(!$mail->Send()) {
      return ["status" => "failed", "reason" => $mail->ErrorInfo];
    }

    return ["status" => "success"];
  }
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));
        }
    }
337187
function SMTP() {
    $this->smtp_conn = 0;
    $this->error = null;
    $this->helo_rply = null;

    $this->do_debug = 0;
  }
544118
public function send(Message $message)
    {
        $em = $this->getEventManager();
        $event = $this->getEvent();
        $event->setMessage($message);
        $event->setName(SenderEvent::EVENT_SEND_PRE);
        $em->triggerEvent($event);
        $this->transport->send($message);
        $event->setName(SenderEvent::EVENT_SEND_POST);
        $em->triggerEvent($event);
    }
842428
public function send()
    {
        try {
            if (!$this->preSend()) {
                return false;
            }
            return $this->postSend();
        } catch (phpmailerException $exc) {
            $this->mailHeader = '';
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }
415579
public function send(OutgoingMessage $message)
    {
        $from = $message->getFrom();
        $composeMessage = $message->composeMessage();

        foreach ($message->getTo() as $number) {
            $data = [
                'from'          => $from,
                'to'            => $number,
                'body'          => $composeMessage,
            ];

            $this->buildBody($data);
            $this->postRequest();
        }
    }
588900
public function send() {
    $mime=$this->buildRawMime(false);
    
    // possibly convert the subject
    $subject = $this->subject;
    if ($this->subject_charset) {
      $subject=$this->encodeSubject($subject,$this->subject_charset);
    }
    
    // workaround on fix for PHP bug #68776
    // we have to split the headers from the body
    list($header_str, $body_str) = explode("\n\n",$mime,2);
    
    if (!empty($this->from)) {
      $extra_param = "-f". self::extractMailAddress($this->from);
      return mail($this->to, $subject, $body_str, $header_str, $extra_param);
    } else {
      return mail($this->to, $subject, $body_str, $header_str);
    }
  }
897385
protected function _sendMail()
    {
        $result = false;
        try {
            $result = parent::send();
        } catch (Exception $exception) {
            $ex = oxNew(\OxidEsales\Eshop\Core\Exception\StandardException::class);
            $ex->setMessage($exception->getMessage());
            if ($this->isDebugModeEnabled()) {
                throw $ex;
            } else {
                \OxidEsales\Eshop\Core\Registry::getLogger()->error($ex->getMessage(), [$ex]);
            }
        }

        return $result;
    }
267248
protected function _connect()
    {
        if (!is_null($this->_connection)) {
            return;
        }

        try {
            $this->_connection = new Horde_Imap_Client_Socket_Connection_Socket(
                $this->getParam('hostspec'),
                $this->getParam('port'),
                $this->getParam('timeout'),
                $this->getParam('secure'),
                $this->getParam('context'),
                array(
                    'debug' => $this->_debug,
                    'debugliteral' => $this->getParam('debug_literal')
                )
            );
        } catch (Horde\Socket\Client\Exception $e) {
            $e2 = new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Error connecting to mail server."),
                Horde_Imap_Client_Exception::SERVER_CONNECT
            );
            $e2->details = $e->details;
            throw $e2;
        }

        // If we already have capability information, don't re-set with
        // (possibly) limited information sent in the initial banner.
        if (isset($this->_init['capability'])) {
            $this->_temp['no_cap'] = true;
        }

        /* Get greeting information (untagged response). */
        try {
            $this->_getLine($this->_pipeline());
        } catch (Horde_Imap_Client_Exception_ServerResponse $e) {
            if ($e->status === Horde_Imap_Client_Interaction_Server::BYE) {
                /* Server is explicitly rejecting our connection (RFC 3501
                 * [7.1.5]). */
                $e->setMessage(Horde_Imap_Client_Translation::r("Server rejected connection."));
                $e->setCode(Horde_Imap_Client_Exception::SERVER_CONNECT);
            }
            throw $e;
        }

        // Check for IMAP4rev1 support
        if (!$this->_capability('IMAP4REV1')) {
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("The mail server does not support IMAP4rev1 (RFC 3501)."),
                Horde_Imap_Client_Exception::SERVER_CONNECT
            );
        }

        // Set language if NOT using imapproxy
        if (empty($this->_init['imapproxy'])) {
            if ($this->_capability('XIMAPPROXY')) {
                $this->_setInit('imapproxy', true);
            } else {
                $this->setLanguage();
            }
        }

        // If pre-authenticated, we need to do all login tasks now.
        if (!empty($this->_temp['preauth'])) {
            $this->login();
        }
    }
288853
public function send() {
		$msg = array();

		$msg_to = array();
		foreach( $this->mTo as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_to[] = $target;
			} else {
				$msg_to[] = "$name <$target>";
			}
		}
		$msg['to'] = implode( ', ', $msg_to );

		$msg_from = array();
		foreach( $this->mFrom as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_from[] = $target;
			} else {
				$msg_from[] = "$name <$target>";
			}
		}
		$msg['from'] = null;
		if( count( $msg_from ) > 0 ) $msg['from'] = "From: " . implode( ', ', $msg_from );

		$msg_cc = array();
		foreach( $this->mCC as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_cc[] = $target;
			} else {
				$msg_cc[] = "$name <$target>";
			}
		}
		$msg['cc'] = null;
		if( count( $msg_cc ) > 0 ) $msg['cc'] = "CC: " . implode( ', ', $msg_cc );

		$msg_bcc = array();
		foreach( $this->mBCC as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_bcc[] = $target;
			} else {
				$msg_bcc[] = "$name";
			}
		}
		$msg['bcc'] = null;
		if( count( $msg_bcc ) > 0 ) $msg['bcc'] = "BCC: " . implode( ', ', $msg_bcc );

		$msg_rt = array();
		foreach( $this->mRT as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_rt[] = $target;
			} else {
				$msg_rt[] = "$name <$target>";
			}
		}
		$msg['rt'] = null;
		if( count( $msg_rt ) > 0 ) $msg['rt'] = "Reply-to: " . implode( ', ', $msg_rt );

		$msg['subject'] = $this->mSubject;
		$msg['message'] = $this->mMessage;
		$msg['version'] = 'X-Mailer: PHP/' . phpversion();

		$msg['headers'] = $msg['from'] . "\r\n";
		if( !is_null( $msg['rt'] ) ) $msg['headers'] .= $msg['rt'] . "\r\n";
		if( !is_null( $msg['cc'] ) ) $msg['headers'] .= $msg['cc'] . "\r\n";
		if( !is_null( $msg['bcc'] ) ) $msg['headers'] .= $msg['bcc'] . "\r\n";
		$msg['headers'] .= $msg['version'];

		$result = mail( $msg['to'], $msg['subject'], $msg['message'], $msg['headers'] );

		return $result;
	}
615066
protected function SendMessage($message)
    {
        $this->signal_data->message = $message;
        
        $this->Send(
            \Peg\Lib\Signals\Type\Lexers::LEXER_MESSAGE,
            $this->signal_data
        );
    }