Send email to recipients using PHP mail
@return boolean
180667
private function sendUsingPHP ()
    {

        // Construct Headers

        $headers	= $this->constructHeaders ();

        // Get template resource

        $tpl	= \Sonic\Sonic::getResource ('tpl');

        // Set smarty template status

        $smarty	= $tpl instanceof \Smarty;

        // If we have a smarty template object

        if ($smarty)
        {

            // Get caching status

            $smartyPrevCache	= $tpl->caching;

            // Disable caching

            $tpl->setCaching (FALSE);

        }

        // For each recipient

        foreach ($this->_recipients as $recipient)
        {

            // Send email

            try
            {

                // Check to make sure the recipients email address is valid

                Parser::_validateEmail ($recipient['email']);

                // Set recipient

                if (isset($recipient['name'])) {
                    $recipientTo = $recipient['name'] . '<' . $recipient['email'] . '>';
                } else {
                    $recipientTo = $recipient['email'];
                }

                // Add recipient header to original headers

                $emailHeaders	= $headers . 'To: ' . $recipientTo . $this->_nl;

                // If we're using smarty

                if ($smarty)
                {

                    // Clear variables

                    $tpl->clearAllAssign ();

                    // Assign variables

                    $tpl->assign ('recipient', $recipient);

                    // Fetch

                    $emailMessage	= $tpl->fetch ('string:' . $this->_message);

                }

                // Else we're not using smarty

                else
                {

                    // Just leave the message as it is

                    $emailMessage	= $this->_message;

                }

                // Send Message

                if (!mail ($recipientTo, $this->_subject, $emailMessage, $emailHeaders))
                {

                    // Add error and return FALSE

                    new \Sonic\Message ('error', 'Cannot send message to: ' . $recipient['email']);

                    // return FALSE

                    return FALSE;

                }

                if (is_callable($this->_callbackMethod))
                {
                    call_user_func ($this->_callbackMethod, $this->_subject, $recipientTo, $this->_fromAddress, $emailMessage);
                }


                // If we're logging the email

                if ($this->logFlag)
                {

                    // Log

                    $this->Log ($recipient['email'], $emailHeaders, $emailMessage, 'phpmail');

                }

            }

                // Else the email address is not valid

            catch (Parser\Exception $e)
            {

                // Add error

                new \Sonic\Message ('error', 'Invalid recipient email address: ' . $recipient['email']);

                // Skip to next recipient

                continue;

            }

        }

        // If we're using smarty

        if ($smarty)
        {

            // Set caching status

            $tpl->caching	= $smartyPrevCache;

        }

        // Return TRUE

        return TRUE;

    }
916928
public function send(
        $from_name,
        array $receivers,
        &$successfulRecipients,
        &$failedRecipients,
        $subject = '',
        $body = '',
        $content_type = 'text/html',
        $charset = 'UTF-8'
    )
    {
        $mailer = \Swift_Mailer::newInstance($this->transport);
        $message = \Swift_Message::newInstance();
        $message->setFrom([$this->_username => $from_name]);
        $message->setTo($receivers);
        $message->setSubject($subject);
        $message->setBody($body, $content_type, $charset);
        $successfulRecipients = $mailer->send($message, $failedRecipients);
        return true;
    }
146040
public function send()
    {
        $subject = 'EVENT';
        if ($this->method == 'CANCEL') {

            $subject = 'CANCELED ' . $subject;
            if (empty($this->uid)) {
                throw(new \Exception('Must set uid to cancel an event.'));
            }
        }

        if (!empty($this->summary)) {
            $subject .= ': ' . substr($this->summary, 0, 20) . '...';
        }

        $to = '"' . $this->organizer->dname . '" <' . $this->organizer->email . '>';

        $mail = new \sb\Email($to, $subject, $this->summary, $to);
        $attendee_emails = Array();
        foreach ($this->attendees as $attendee) {
            $attendee_emails[] = '"' . $attendee->dname . '" <' . $attendee->email . '>';
        }

        $mail->cc = $attendee_emails;
        $mail->addIcalendarEvent($this);
        return $mail->send();
    }
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;
        }
    }
340258
public function _sendMail()
    {
        // If sending multiple messages per session use existing adapter
        if (!($this->_connection instanceof Zend_Mail_Protocol_Smtp)) {
            // Check if authentication is required and determine required class
            $connectionClass = 'Zend_Mail_Protocol_Smtp';
            if ($this->_auth) {
                $connectionClass .= '_Auth_' . ucwords($this->_auth);
            }
            if (!class_exists($connectionClass)) {
                // require_once 'Zend/Loader.php';
                Zend_Loader::loadClass($connectionClass);
            }
            $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
            $this->_connection->connect();
            $this->_connection->helo($this->_name);
        } else {
            // Reset connection to ensure reliable transaction
            $this->_connection->rset();
        }

        // Set sender email address
        $this->_connection->mail($this->_mail->getReturnPath());

        // Set recipient forward paths
        foreach ($this->_mail->getRecipients() as $recipient) {
            $this->_connection->rcpt($recipient);
        }

        // Issue DATA command to client
        $this->_connection->data($this->header . Zend_Mime::LINEEND . $this->body);
    }
1250957
public function send()	{

		$this->buildHeaders();
		$this->buildMsg();

		if (!self::$debug) {
			return $this->sendMail();
		}

		$headers = [];
		foreach($this->headers as $k => $v) {
			$headers[] = "$k: $v";
		}
		echo '<div style="border: solid 2px #888; background:#efe; font-family: monospace; font-size: 1em; padding: 1em; margin: 1em;">';
		echo is_array($this->receiver) ? implode(', ', $this->receiver) : $this->receiver, '<hr>';
		echo implode('<br>', $headers), '<hr>', $this->subject, '<hr>', nl2br($this->msg);
		echo '</div>';

		return true;

	}
1277256
public function send()
    {
        $to = $this->getToForSend();
        $headers = $this->getHeadersForSend();

        if (empty($to)) {
            throw new \RuntimeException(
                'Unable to send, no To address has been set.'
            );
        }

        if ($this->hasAttachments()) {
            $message  = $this->assembleAttachmentBody();
            $headers .= PHP_EOL . $this->assembleAttachmentHeaders();
        } else {
            $message = $this->getWrapMessage();
        }

        return mail($to, $this->_subject, $message, $headers, $this->_params);
    }
50257
public function send()
	{
		// load the mail configuration
		$config = \CCConfig::create( 'mail' );
		
		// when mailing is disabled do nothing just return
		if ( $config->disabled === true )
		{
			return;
		}
		
		// we cannot send a mail without recipients
		if ( empty( $this->to ) )
		{
			throw new Exception( "Cannot send mail without recipients." );
		}
		
		// is a catch all enabled?
		if ( $config->get( 'catch_all.enabled' ) === true )
		{
			// to be able to modify the mail without removing
			// the user options we have to clone the mail
			$mail = clone $this;
			
			// we have to remove all recipients ( to, ccc, bcc ) and set them
			// to our catch all recipients
			$mail->to = array();
			$mail->cc = array();
			$mail->bcc = array();
			
			$mail->to( $config->get( 'catch_all.addresses' ) );
			
			// transport the cloned mail
			return $mail->transport( $config->get( 'catch_all.transporter' ) );
		}
		
		// transport the mail
		$this->transport();
	}
275103
public function send()
    {
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        // loads submited values
        $this->_aRegParams = $aParams;

        if (!$aParams['oxuser__oxusername']) {
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');

            return;
        } elseif (!oxNew(\OxidEsales\Eshop\Core\MailValidator::class)->isValidEmail($aParams['oxuser__oxusername'])) {
            // #1052C - eMail validation added
            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('MESSAGE_INVALID_EMAIL');

            return;
        }

        $blSubscribe = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("subscribeStatus");

        $oUser = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
        $oUser->oxuser__oxusername = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxusername'], \OxidEsales\Eshop\Core\Field::T_RAW);

        // if such user does not exist
        if (!$oUser->exists()) {
            // and subscribe is off - error, on - create
            if (!$blSubscribe) {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('NEWSLETTER_EMAIL_NOT_EXIST');

                return;
            } else {
                $oUser->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field(1, \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxrights = new \OxidEsales\Eshop\Core\Field('user', \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxshopid = new \OxidEsales\Eshop\Core\Field(\OxidEsales\Eshop\Core\Registry::getConfig()->getShopId(), \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxfname = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxfname'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxlname = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxlname'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxsal = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxsal'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $oUser->oxuser__oxcountryid = new \OxidEsales\Eshop\Core\Field($aParams['oxuser__oxcountryid'], \OxidEsales\Eshop\Core\Field::T_RAW);
                $blUserLoaded = $oUser->save();
            }
        } else {
            $blUserLoaded = $oUser->load($oUser->getId());
        }


        // if user was added/loaded successfully and subscribe is on - subscribing to newsletter
        if ($blSubscribe && $blUserLoaded) {
            //removing user from subscribe list before adding
            $oUser->setNewsSubscription(false, false);

            $blOrderOptInEmail = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blOrderOptInEmail');
            if ($oUser->setNewsSubscription(true, $blOrderOptInEmail)) {
                // done, confirmation required?
                if ($blOrderOptInEmail) {
                    $this->_iNewsletterStatus = 1;
                } else {
                    $this->_iNewsletterStatus = 2;
                }
            } else {
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay('MESSAGE_NOT_ABLE_TO_SEND_EMAIL');
            }
        } elseif (!$blSubscribe && $blUserLoaded) {
            // unsubscribing user
            $oUser->setNewsSubscription(false, false);
            $this->_iNewsletterStatus = 3;
        }
    }
1054528
public function sendEmail()
    {
        $user = User::findOne([
            'email' => $this->email,
            'status' => User::STATUS_INACTIVE
        ]);

        if ($user === null) {
            return false;
        }

        return Yii::$app
            ->mailer
            ->compose(
                ['html' => 'emailVerify-html', 'text' => 'emailVerify-text'],
                ['user' => $user]
            )
            ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
            ->setTo($this->email)
            ->setSubject('Account registration at ' . Yii::$app->name)
            ->send();
    }
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);
	}
594587
private function sendMail()
    {
        IlluminateMail::send($this->target->view, [], function ($message) {
            $fromAddress = array_get($this->target->config, 'from.address');

            $message->returnPath($fromAddress);

            $message->cc($fromAddress);

            $message->bcc($fromAddress);

            $message->replyTo($fromAddress);

            $message->to($this->target->to);

            $message->subject($this->target->subject);
        });
    }
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;
    }
1208843
function mail_send($header, $body) {
      //$to = substr($this->addr_append("To", $this->to), 4, -2);

      // Cannot add Bcc's to the $to
      $to = $this->to[0][0]; // no extra comma
      for($i = 1; $i < count($this->to); $i++)
         $to .= sprintf(",%s", $this->to[$i][0]);

      if ($this->Sender != "" && PHP_VERSION >= "4.0")
      {
         $old_from = ini_get("sendmail_from");
         ini_set("sendmail_from", $this->Sender);
      }

      if ($this->Sender != "" && PHP_VERSION >= "4.0.5")
      {
         // The fifth parameter to mail is only available in PHP >= 4.0.5
         $params = sprintf("-f %s", $this->Sender);
         $rt = @mail($to, $this->Subject, $body, $header, $params);
      }
      else
      {
         $rt = @mail($to, $this->Subject, $body, $header);
      }

      if (isset($old_from))
         ini_set("sendmail_from", $old_from);

      if(!$rt)
      {
         $this->error_handler("Could not instantiate mail()");
         return false;
      }

      return true;
   }
964345
public function send($mail)
    {
        $mail = clone $mail;

        try {
            if (!$this->_connection) {
                $this->connect();
            }

            if (($from = $mail->returnPath()) || ($from = $mail->from())) {
                $this->write("MAIL FROM:<" . $from->email() . ">", 250);
            }

            foreach ($mail->recipients() as $recipient) {
                $this->write("RCPT TO:<" . $recipient->email() . ">", [250, 251]);
            }

            $this->write('DATA', 354);
            $this->write(preg_replace('~^\.~m', '..', $mail->toMessage()));
            $this->write('.', 250);

            if (!$this->_persistent) {
                $this->write('QUIT', 221);
                $this->disconnect();
            }
        } catch (NetException $exception) {
            if ($this->_connection) {
                $this->disconnect();
            }
            throw $exception;
        }
    }
164918
public function send()
    {
        if (!$this->_user->has('email') || !$this->_user->has('name')) {
            throw new BadMethodCallException(__d('user', 'Missing "name" or "email" property when trying to send the email.'));
        }

        if ($this->config('updateToken') === true) {
            $this->loadModel('User.Users');
            $this->_user->updateToken();
        }

        $subject = $this->_parseVariables((string)$this->subject());
        $body = $this->_parseVariables((string)$this->body());

        if (empty($subject) || empty($body)) {
            return false;
        }

        $sender = new Email($this->config('emailConfig'));
        $sent = false;
        try {
            $sent = $sender
                ->to($this->_user->get('email'), $this->_user->get('name'))
                ->subject($subject)
                ->send($body);
        } catch (\Exception $e) {
            return false;
        }

        return $sent;
    }
1314883
public function sendNotification()
    {
        if (($from = self::config()->get('mail_sender')) && empty($from)) {
            $from = Config::inst()->get('Email', 'admin_email');
        }

        if (($to = self::config()->get('mail_receiver')) && empty($to)) {
            $to = Config::inst()->get('Email', 'admin_email');
        }

        $email = new Email();
        $email->setSubject(_t(
            'NotificationMail.TITLE',
            'Nieuwe reservering voor {event}',
            null, array('event' => $this->Event()->Title)
        ));

        $email->setFrom($from);
        $email->setTo($to);
        $email->setTemplate('NotificationMail');
        $email->populateTemplate($this);
        $this->extend('updateNotificationMail', $email);
        return $email->send();
    }