Setup mailer.

@return \Illuminate\Contracts\Mail\Mailer
181072
public function configureIlluminateMailer(MailerContract $mailer): MailerContract
    {
        $from = $this->memory->get('email.from');

        // If a "from" address is set, we will set it on the mailer so that
        // all mail messages sent by the applications will utilize the same
        // "from" address on each one, which makes the developer's life a
        // lot more convenient.
        if (\is_array($from) && ! empty($from['address'])) {
            $this->from = $from;
            $mailer->alwaysFrom($from['address'], $from['name']);
        }

        if ($this->queue instanceof QueueContract) {
            $mailer->setQueue($this->queue);
        }

        $mailer->setSwiftMailer(new Swift_Mailer($this->transport->driver()));

        return $mailer;
    }
1177915
public function getMailer() {
		if ($this->mailer === null) {
			$prefs = $this->getPreferenceLoader()->getSystemPreferences();
			switch ($prefs->getMailTransport()) {
				case SystemPreferences::MAIL_TRANSPORT_SMTP:
					$transport = new Swift_SmtpTransport($prefs->getSmtpServer(), $prefs->getSmtpPort());
					$transport->setUsername($prefs->getSmtpUsername());
					$transport->setPassword($prefs->getSmtpPassword());
					$encryption = $prefs->getSmtpEncryption();
					if ($encryption != SystemPreferences::SMTP_ENCRYPTION_NONE) {
						$transport->setEncryption($encryption);
					}
					break;

				case SystemPreferences::MAIL_TRANSPORT_SENDMAIL:
					$transport = new Swift_SendmailTransport($prefs->getSendmail());
					break;

				case SystemPreferences::MAIL_TRANSPORT_MAIL:
				default:
					$transport = new Swift_MailTransport();
					break;
			}

			$this->mailer = new Swift_Mailer($transport);
		}

		return $this->mailer;
	}
500975
public function handler(): Response
    {
        $mailer = new Mailer([
            'driver' => 'smtp',
            'host' => 'host',
            'port' => 0,
            'encryption' => '',
            'username' => 'username',
            'password' => 'password',
            'sender' => 'sender',
            'remark' => ''
        ]);
        if (Mailer::count() === 0) {
            $mailer->default(true);
        }
        $mailer->save();
        $this->log('info', 'Create a mailer [' . $mailer->getSender() . ']');
        return response([
            'id' => $mailer->getId()
        ]);
    }
346372
public function email() {
        $this->check_role = 'email';
        $result = $this->filter($this->value, FILTER_VALIDATE_EMAIL);
        $this->checkResult($result);
        return $this;
    }
1267265
public function registerEmailEngine()
    {
        $app = $this->app;

        $app->bind('email.compiler', function () use ($app) {
            $cache = $app['config']['view.compiled'];
            $css = $app['config']['view.emails.css_files'];

            return new Compiler($app['files'], $cache, $css);
        });

        $app['view']->addExtension('email.php', 'email', function () use ($app) {
            return new CompilerEngine($app['email.compiler']);
        });
    }
1308382
public function registerSwiftMailer()
    {
        $this->registerSwiftTransport();

        // Once we have the transporter registered, we will register the actual Swift
        // mailer instance, passing in the transport instances, which allows us to
        // override this transporter instances during app start-up if necessary.
        $this->app->singleton('swift.mailer', function () {
            if ($domain = $this->app->make('config')->get('mail.domain')) {
                Swift_DependencyContainer::getInstance()
                                ->register('mime.idgenerator.idright')
                                ->asValue($domain);
            }

            return new Swift_Mailer($this->app['swift.transport']->driver());
        });
    }
532754
public function register()
    {
        $this->create('mail', function () {
            // return new Mailer();
            $c = new Configuration();
            $config = $c->from('mail');

            $mail = new Mailer($config->get('host'), $config->get('port'),
                $config->get('smtp_auth'), $config->get('encryption'));

            return $mail->setAuthentication($config->get('user'), $config->get('pass'));
        });
    }
1338548
public function init()
    {
        if (!class_exists('Swift_MailTransport')) {
            throw new \Exception('SwiftMailer need to be installed');
        }
        $transport = null;
        switch ($this->config['transport']) {
            case self::TRANSPORT_SENDMAIL:
                $transport = new \Swift_SendmailTransport();
                break;
            case self::TRANSPORT_SMTP:
                $transport = (new \Swift_SmtpTransport(isset($this->config['host'])
                            ? $this->config['host'] : 'localhost',
                    isset($this->config['port']) ? $this->config['port'] : 25,
                    isset($this->config['security']) ? $this->config['security']
                            : ''))
                    ->setUsername($this->config['username'])
                    ->setPassword($this->config['password']);
                break;
            case self::TRANSPORT_MAIL:
            default:
                $transport = new \Swift_MailTransport();
        }
        $this->mailer = new \Swift_Mailer($transport);
        return $this;
    }
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();
    }
1258241
public function boot()
    {
        Validator::extend('email_checker', function ($attribute, $value, $parameters, $validator) {
            $email = new EmailChecker();

            return $email->check($value);
        }, 'Invalid Email Address');
    }
333231
public function send(): Letter
    {
        $options = [
            'headers' => [
                'Content-Source' => $this->getEndpointMailbox().'/letters/'.$this->getLetterId(),
            ],
        ];

        if ($this->getEnvelope()->isHybridLetter() && null !== $this->getDeliveryOptions()) {
            $options['headers']['Content-Type'] = $this->getDeliveryOptions()->getMimeType();
            $options['json']                    = $this->getDeliveryOptions();
        }

        $this->getHttpClientForSend()->request('POST', '/deliveries', $options);

        return $this;
    }
593837
public function from($mail, $name = null)
    {
        $this->mailer->setFrom($mail, $name);
        return $this;
    }
1006616
protected function create()
    {
        $this->user = app(\SuperV\Platform\Domains\Auth\Contracts\User::class)->create([
            'name'    => $this->request['name'],
            'email'    => $this->request['email'],
            'password' => bcrypt($this->request['password']),
        ]);

        return $this;
    }
477554
protected function getMailer()
    {
        $mailer = new \PHPMailer();
        
        $SMTPConfig = $this->getOption(self::CONFIG_SMTP_CONFIG);
        
        $mailer->IsSMTP();
        $mailer->SMTPKeepAlive = true;
        $mailer->Debugoutput = 'error_log';
        
        $mailer->Host = $SMTPConfig['SMTP_HOST'];
        $mailer->Port = $SMTPConfig['SMTP_PORT'];
        $mailer->Username = $SMTPConfig['SMTP_USER'];
        $mailer->Password = $SMTPConfig['SMTP_PASS'];
        
        if (isset($SMTPConfig['DEBUG_MODE'])) {
            $mailer->SMTPDebug = $SMTPConfig['DEBUG_MODE'];
        }
        if (isset($SMTPConfig['Mailer'])) {
            $mailer->Mailer = $SMTPConfig['Mailer'];
        }
        if (isset($SMTPConfig['SMTP_AUTH'])) {
            $mailer->SMTPAuth = $SMTPConfig['SMTP_AUTH'];
        }
        if (isset($SMTPConfig['SMTP_SECURE'])) {
            $mailer->SMTPSecure = $SMTPConfig['SMTP_SECURE'];
        }
        
        return $mailer;
    }
1253662
public function sendTicket()
    {
        // Get the mail sender or fallback to the admin email
        if (empty($from = Reservation::config()->get('mail_sender'))) {
            $from = Config::inst()->get('Email', 'admin_email');
        }

        $email = new Email();
        $email->setSubject(_t(
            'AttendeeMail.TITLE',
            'Your ticket for {event}',
            null,
            array(
                'event' => $this->Event()->Title
            )
        ));
        $email->setFrom($from);
        $email->setTo($this->getEmail());
        $email->setTemplate('AttendeeMail');
        $email->populateTemplate($this);
        $this->extend('updateTicketMail', $email);
        return $email->send();
    }
868567
protected function getMailer()
    {
        $transport = null;
        if ($this->configurationManager->getSetting('mailer.type') === 'sendmail') {
            $transport = \Swift_SendmailTransport::newInstance($this->configurationManager->getSetting('mailer.sendmailCommand'));
        } else if ($this->configurationManager->getSetting('mailer.type') === 'smtp') {
            $host = $this->configurationManager->getSetting('mailer.smtpHost');
            $port = $this->configurationManager->getSetting('mailer.smtpPort');
            $username = $this->configurationManager->getSetting('mailer.smtpUsername');
            $password = $this->configurationManager->getSetting('mailer.smtpPassword');
            
            $transport = \Swift_SmtpTransport::newInstance($host, $port);
            $transport->setUsername($username);
            $transport->setPassword($password);
        }
        
        if ($transport === null) {
            throw new Exception('No mail transport defined. Please check your configuration.');
        }

        return \Swift_Mailer::newInstance($transport);
    }
238498
protected function loadMailer()
    {
        $this->mailTarget = false;

        if (isset($this->formData['gct_target']) && isset($this->mailTargets[$this->formData['gct_target']])) {
            $this->mailTarget = $this->formData['gct_target'];
        } else {
            reset($this->mailTargets);
            $this->mailTarget = key($this->mailTargets);
        }
        $this->mailer = $this->loader->getMailLoader()->getMailer($this->mailTarget);
    }