Prepares the `from` email address.

@param \Cake\Mailer\Email $email Email instance
@return array
966962
protected function _prepareFromAddress($email)
    {
        $from = $email->getReturnPath();
        if (empty($from)) {
            $from = $email->getFrom();
        }

        return $from;
    }
799642
public function setSender($email)
    {
        $mail = new Email($email);
        $parts = $mail->parse();

        $this->fromUser = $parts[0];
        $this->fromDomain = $parts[1];
    }
676290
public function setEmail($email)
    {
        if (!is_string($email)) {
            $email = strval($email);
        }

        $this->email = $email;
    }
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;
    }
1052742
public function createUser($email)
    {
        $contents = $this
            ->call('POST', self::USERS_RESOURCE, ['json' => [
                'email' => $email,
            ]], false)
            ->getBody()
            ->getContents()
        ;

        return UserModel::createFromJsonResponse($contents);
    }
632546
public function loadByEmail($email)
    {
        $query = $this->handler->createSelectQuery();
        $query->select(
            $this->handler->quoteColumn('contentobject_id', 'ezuser'),
            $this->handler->quoteColumn('login', 'ezuser'),
            $this->handler->quoteColumn('email', 'ezuser'),
            $this->handler->quoteColumn('password_hash', 'ezuser'),
            $this->handler->quoteColumn('password_hash_type', 'ezuser'),
            $this->handler->quoteColumn('is_enabled', 'ezuser_setting'),
            $this->handler->quoteColumn('max_login', 'ezuser_setting')
        )->from(
            $this->handler->quoteTable('ezuser')
        )->leftJoin(
            $this->handler->quoteTable('ezuser_setting'),
            $query->expr->eq(
                $this->handler->quoteColumn('user_id', 'ezuser_setting'),
                $this->handler->quoteColumn('contentobject_id', 'ezuser')
            )
        )->where(
            $query->expr->eq(
                $this->handler->quoteColumn('email', 'ezuser'),
                $query->bindValue($email, null, \PDO::PARAM_STR)
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
1032783
protected function prepareEmails(array $emails)
    {
        foreach ($emails as $email) {
            $email->setStatus(SpoolEmailStatus::STATUS_SENDING);
            $email->setSentAt(null);
            $this->om->persist($email);
        }

        $this->om->flush();
        reset($emails);

        return $emails;
    }
1105311
public function send(Email $email)
    {
        if (null === $email->getFrom()) {
            $email->setFrom($this->from);
        }
        $message = $this->mapper->fromEmail($email);

        // Try to send the mail.
        $state = $this->mailer->send($message);

        $deliveryStatus = (\Swift_Events_SendEvent::RESULT_SUCCESS === $state);

        $email->setSentState($deliveryStatus)
            ->setSentDate($deliveryStatus ? new \DateTime() : null);

        return $email;
    }
1125463
public function setEmail($email)
    {
        if (!empty($email) && is_string($email) && ctype_print($email)) {
            $this->email = trim($email);
        }

        return $this;
    }
516017
private function getAccessLevels($email)
    {
        foreach ($this->hostedDomains as $hostedDomain) {
            if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) {
                return $hostedDomain['access_levels'];
            }
        }

        return null;
    }
699800
public function set_sender($email)
        {
            $parts = $this->parse_email($email);
            $this->from_user = $parts[0];
            $this->from_domain = $parts[1];
        }
1256381
protected function _sendData($email)
    {
        $this->_smtpSend('DATA', '354');

        $headers = $this->_headersToString($this->_prepareMessageHeaders($email));
        $message = $this->_prepareMessage($email);

        $this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n.");
        $this->_content = ['headers' => $headers, 'message' => $message];
    }
628644
public function logEmailInDatabase($email)
    {
        $emailLogModel = TableRegistry::getTableLocator()->get('EmailLogs');
        $email2save = [
            'from_address' => json_encode($this->getFrom()),
            'to_address' => json_encode($this->getTo()),
            'cc_address' => json_encode($this->getCc()),
            'bcc_address' => json_encode($this->getBcc()),
            'subject' => $this->getOriginalSubject(),
            'headers' => json_encode($this->getHeaders()),
            'message' => $email['message']
        ];
        return $emailLogModel->save($emailLogModel->newEntity($email2save));
    }
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;
	}
986407
public function searchByEmailArray($email) {
		$results = $this->ldap->search($this->basedn,
			$this->search_mail_array . '=' . $email);
		return $results;
	}
729495
public function searchByEmail($email) {
		$results = $this->ldap->search($this->basedn,
			$this->search_mail . '=' . $email);
		return $results;
	}
564586
public function setSender($email)
    {
        if ($this->isValidEmail($email) === true) {
            $this->sender = $email;
        } else {
            return false;
        }
    }