@inheritdoc

@return EmailConfiguration
963973
public function extract(array $configurations)
    {
        $emailConfiguration = new EmailConfiguration();

        foreach ($configurations as $configuration) {
            switch ($configuration->getKey()) {
                case self::EMAIL_SENDER:
                    $emailConfiguration->setEmailSender($configuration->getValue());
                    break;
                case self::EMAIL_SENDER_NAME:
                    $emailConfiguration->setEmailSenderName($configuration->getValue());
                    break;
                case self::EMAIL_SUBJECT_PREFIX:
                    $emailConfiguration->setEmailSubjectPrefix($configuration->getValue());
                    break;
                case self::EMAIL_BODY_SIGNATURE:
                    $emailConfiguration->setEmailBodySignature($configuration->getValue());
                    break;
            }
        }

        return $emailConfiguration;
    }
838450
public function getEmailConfig()
    {
        if (! isset($this->emailConfig['subject']) ||
            ! is_string($this->emailConfig['subject'])
        ) {
            $this->emailConfig['subject'] = 'Cronjob execution';
        }

        if (! isset($this->emailConfig['from'])) {
            $this->emailConfig['from'] = ['cronjob@server.my' => 'My Email Server'];
        }

        if (! isset($this->emailConfig['body']) ||
            ! is_string($this->emailConfig['body'])
        ) {
            $this->emailConfig['body'] = 'Cronjob output attached';
        }

        if (! isset($this->emailConfig['transport']) ||
            ! ($this->emailConfig['transport'] instanceof \Swift_Transport)
        ) {
            $this->emailConfig['transport'] = new \Swift_SendmailTransport();
        }

        return $this->emailConfig;
    }
144911
public function withVerifiedEmail($email)
    {
        $request = clone $this;
        $request->email = $email instanceof Email ? $email : new Email($email);
        $request->emailIsVerified = true;

        return $request;
    }
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;
    }
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;
    }
328761
public function setEmailType(\Sulu\Bundle\ContactBundle\Entity\EmailType $emailType)
    {
        $this->emailType = $emailType;

        return $this;
    }
489775
public function setEmail($email)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidParamException('Invalid email format: "' . $email . '"');
        } else {
            $this->email = $email;
        }

        return $this;
    }
1204141
public function setEmail($email)
    {
        $this->email = $email;
        $this->referenceId = null;
        $this->executed = false;
        return $this;
    }
875501
public function addEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails)
    {
        $this->emails[] = $emails;

        return $this;
    }
176475
private function getMailSystem()
    {
        if (isset($this->config['mail']) && isset($this->config['mail']['mailsystem'])) {
            $system = $this->config['mail']['mailsystem'];
            $class = 'GLFramework\\Mail\\' . $system;
            if (class_exists($class)) {
                return new $class($this->config);
            }
        }
        return new Mail\Mail($this->config);
    }
1344067
protected function configureMail(array $config = [])
    {
        $config = array_merge([
            'MAIL_DRIVER'     => null,
            'MAIL_HOST'       => null,
            'MAIL_PORT'       => null,
            'MAIL_USERNAME'   => null,
            'MAIL_PASSWORD'   => null,
            'MAIL_ADDRESS'    => null,
            'MAIL_NAME'       => null,
            'MAIL_ENCRYPTION' => null,
        ], $config);

        // Don't continue with these settings if we're not interested in notifications.
        if (!$this->confirm('Do you want Cachet to send mail notifications?')) {
            return;
        }

        $config['MAIL_DRIVER'] = $this->choice('What driver do you want to use to send notifications?', [
            'smtp'      => 'SMTP',
            'mail'      => 'Mail',
            'sendmail'  => 'Sendmail',
            'mailgun'   => 'Mailgun',
            'mandrill'  => 'Mandrill',
            'ses'       => 'Amazon SES',
            'sparkpost' => 'SparkPost',
            'log'       => 'Log (Testing)',
        ]);

        if (!$config['MAIL_DRIVER'] === 'log') {
            if ($config['MAIL_DRIVER'] === 'smtp') {
                $config['MAIL_HOST'] = $this->ask('Please supply your mail server host');
            }

            $config['MAIL_ADDRESS'] = $this->ask('What email address should we send notifications from?');
            $config['MAIL_USERNAME'] = $this->ask('What username should we connect as?');
            $config['MAIL_PASSWORD'] = $this->secret('What password should we connect with?');
        }

        // Format the settings ready to display them in the table.
        $this->formatConfigsTable($config);

        if (!$this->confirm('Are these settings correct?')) {
            return $this->configureMail($config);
        }

        foreach ($config as $setting => $value) {
            $this->writeEnv($setting, $value);
        }
    }
346372
public function email() {
        $this->check_role = 'email';
        $result = $this->filter($this->value, FILTER_VALIDATE_EMAIL);
        $this->checkResult($result);
        return $this;
    }
9798
public function build(Email $email): Email
    {
        foreach ($this->parts as $part) {
            $resolver = $this->registry->getResolverForPart($part);
            $resolver->addPart($email, $part);
        }

        $this->parts = [];

        return $email;
    }
658691
public function setCc(array $addresses): Email
    {
        $addresses = $this->transformAddressesToArray($addresses);
        $this->message->setCc($addresses);

        return $this;
    }
109903
public function send($email)
    {
        $this->email = $email;
        $this->attachments = $email->getAttachments();

        $addresses = $this->addressManager->manageAddresses($this->email);

        $this->needsSpool = (count($addresses) > 1);

        if ($this->email->getIsTest()) {
            return $this->directSend($this->email->getTestAddressAsArray());
        }

        if ($this->needsSpool) {
            return $this->spoolSend($addresses);
        }

        return $this->directSend($addresses);
    }
431656
public function setEmail($email = '')
    {
        $email = (string)$email;

        // According to the docs, emails should be lowercase: https://en.gravatar.com/site/implement/hash/
        $email = trim($email);
        $email = strtolower($email);

        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException('Email should be a valid email address');
        }

        $this->email = md5($email);

        return $this;
    }
109909
public function setTo($to)
    {
        if ($to instanceof Email) {
            $to = [$to];
        }

        foreach ($to as $email) {
            if (!$email instanceof Email) {
                throw new MailerException('Email must be an instance of \Webiny\Component\Mailer\Email.');
            }
            $this->addTo($email);
        }

        return $this;
    }