Converts an Email object into a \Swift_Message object.

@param Email $email

@return \Swift_Message
499658
public function convert(Email $email): \Swift_Message
    {
        $message = $this->createInstance()->setSubject($email->getSubject());
        $message->setBoundary($boundary = \md5(\uniqid()));

        $this->addAddresses($email, $message);
        $this->addParts($email, $message, $boundary);
        $this->addHeaders($email, $message);
        $this->addAttachments($email, $message);

        if ($contentType = $email->getContentType()) {
            $message->setContentType($contentType);
        }

        return $message;
    }
1210972
public function setEmail($email)
    {
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $this->_options['email'] = $email;
            $this->_options['hash'] = strtolower(md5(trim($this->_options['email'])));
        } else {
            throw new \Exception('The email is in an invalid format!');
        }

        return $this;
    }
414827
public function setTo($email)
    {
        if (is_string($email)) {
            $email = [ $email ];
        }

        if (!is_array($email)) {
            throw new InvalidArgumentException(
                'Must be an array of recipients.'
            );
        }

        $this->to = [];

        // At this point, `$email` can be an _email array_ or an _array of emails_...
        if (isset($email['email'])) {
            // Means we're not dealing with multiple emails
            $this->addTo($email);
        } else {
            foreach ($email as $recipient) {
                $this->addTo($recipient);
            }
        }

        return $this;
    }
380041
public function to($emails)
    {
        if (is_array($emails)) {
            $this->to = $emails;
        } else {
            $this->to = (array) $emails;
        }

        return $this;
    }
881363
protected function parse_email($email)
        {
            $parts  = explode('@', $email);
            $domain = array_pop($parts);
            $user   = implode('@', $parts);
            return array($user, $domain);
        }
245169
public static function email($email)
    {
        $html = self::getInstance()->html;
        $args = func_get_args();
        return call_user_func_array(array($html, __FUNCTION__), $args);
    }
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;
    }
1262287
private function emailToUsername($email = null)
    {
        if ($user = get_user_by('email', $email)) {
            if (isset($user->user_login)) {
                return $user->user_login;
            }
        }

        return null;
    }
1067862
static function email2user($email)
    {
        $rcube = rcube::get_instance();
        $plugin = $rcube->plugins->exec_hook('email2user',
            array('email' => $email, 'user' => NULL));

        return $plugin['user'];
    }
483134
public function send(\SendGrid\Mail\Mail $email)
    {
        return $this->client->mail()->send()->post($email);
    }
404854
protected function normalizeEmail($email)
    {
        if (is_array($email)) {

            $emails = [];

            foreach ($email as $k => $v) {
                if (is_int($k)) {
                    $emails[$k] = $this->getManager()->normalizeEmail($v);
                } else {
                    $k = $this->getManager()->normalizeEmail($k);
                    $emails[$k] = $v;
                }
            }

            return $emails;

        } else {
            return $this->getManager()->normalizeEmail($email);
        }
    }
565072
protected function encodeEmail($email)
    {
        if ($email == '')
        {
            return '';
        }
        if (strpos($email, '@') === false)
        {
            return $email; // see #6241
        }
        $arrChunks = explode('@', $email);
        $strHost = array_pop($arrChunks);
        return implode('@', $arrChunks) . '@' . static::encode($strHost);
    }
1111998
protected static function validateEmailAddress($email) {
		if (empty($email)) {
			throw new InvalidEmailException();
		}

		$email = \trim($email);

		if (!\filter_var($email, \FILTER_VALIDATE_EMAIL)) {
			throw new InvalidEmailException();
		}

		return $email;
	}
949410
public function withUnverifiedEmail($email)
    {
        $request = clone $this;
        $request->email = $email instanceof Email ? $email : new Email($email);
        $request->emailIsVerified = false;

        return $request;
    }
529280
public function changeEmail($email)
    {
        if ($email !== $this->email) {
            $this->email = $email;

            $this->raise(new EmailChanged($this));
        }

        return $this;
    }
892301
private function createEmailHash(string $email): string
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException('Invalid email address');
        }

        return md5(strtolower(trim($email)));
    }
934349
public function obfuscate($email)
    {
        $output = null;
        for ($i = 0; $i < strlen($email); $i++) {
            $output .= '&#'.ord($email[$i]).';';
        }
        
        return $output;
    }