Creates a contact.

@param string $email

@return null
@throws \Exception
429662
public function postContacts($email)
    {
        $url = $this->getApiEndpoint() . self::REST_CONTACTS;
        $data = [
            'Email' => $email,
            'EmailType' => 'Html',
        ];
        $this->setUrl($url)
            ->setVerb('POST')
            ->buildPostBody($data);

        $response = $this->execute();

        if (isset($response->message)) {
            $message = $email . ' , url ' . $url . ', ' . $response->message;
            $this->helper->debug('postContacts', [$message]);
        }

        return $response;
    }
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;
    }
113450
public function send(Email $email)
    {
        $eol = PHP_EOL;
        if (isset($this->_config['eol'])) {
            $eol = $this->_config['eol'];
        }
        $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']);
        $to = $headers['To'];
        unset($headers['To']);
        foreach ($headers as $key => $header) {
            $headers[$key] = str_replace(["\r", "\n"], '', $header);
        }
        $headers = $this->_headersToString($headers, $eol);
        $subject = str_replace(["\r", "\n"], '', $email->getSubject());
        $to = str_replace(["\r", "\n"], '', $to);

        $message = implode($eol, $email->message());

        $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
        $this->_mail($to, $subject, $message, $headers, $params);

        $headers .= $eol . 'To: ' . $to;
        $headers .= $eol . 'Subject: ' . $subject;

        return ['headers' => $headers, 'message' => $message];
    }
771528
public function setEmail($email)
    {
        $email = (string) $email;

        if ($this->exists() && $this->email !== $email) {
            $this->updated['email'] = true;
        }

        $this->email = $email;

        return $this;
    }
449315
public function getUserByEMail(string $email)
    {
        $retval = null;

        if (strlen($email) > 0) {
            $nb_user = CNabuUser::findByEMail($this, $email);
            if ($nb_user instanceof CNabuUser && $nb_user->validateCustomer($this)) {
                $nb_user->setCustomer($this);
                $retval = $nb_user;
            }
        }

        return $retval;
    }
1241071
private function createCustomer(
        $email,
        $firstName = null,
        $lastName = null,
        \DateTimeInterface $createdAt = null,
        $phoneNumber = null
    ) {
        /** @var CustomerInterface $customer */
        $customer = $this->customerFactory->createNew();

        $customer->setFirstName($firstName);
        $customer->setLastName($lastName);
        $customer->setEmail($email);
        $customer->setPhoneNumber($phoneNumber);
        if (null !== $createdAt) {
            $customer->setCreatedAt($createdAt);
        }

        $this->sharedStorage->set('customer', $customer);

        return $customer;
    }
245169
public static function email($email)
    {
        $html = self::getInstance()->html;
        $args = func_get_args();
        return call_user_func_array(array($html, __FUNCTION__), $args);
    }
380354
public function email($contact)
    {
        if ($this->isStringLike($contact) && $this->isMapped($contact)) {
            return $this->mappedEmail($contact);
        }

        if ($this->isStringLike($contact) && $this->isEmailAddress($contact)) {
            return $contact;
        }

        if (!is_object($contact)) {
            throw new RuntimeException('No idea how to extract an email address of '.gettype($contact));
        }

        foreach ($this->possibleEmailMethods as $method) {
            if (method_exists($contact, $method)) {
                return $contact->{$method}();
            }
        }

        foreach ($this->possibleEmailProperties as $property) {
            if (isset($contact->{$property})) {
                return $contact->{$property};
            }
        }

        throw new RuntimeException('No idea how to extract an email address of '.get_class($contact));
    }
817652
public function send(\BearFramework\Emails\Email $email): void
    {
        $app = App::get();
        $email = clone($email);

        if ($this->hasEventListeners('beforeSendEmail')) {
            $eventDetails = new \BearFramework\Emails\BeforeSendEmailEventDetails($email);
            $this->dispatchEvent('beforeSendEmail', $eventDetails);
            if ($eventDetails->preventDefault) {
                return;
            }
        }

        if (empty($this->senders)) {
            throw new \Exception('No email senders added.');
        }

        foreach ($this->senders as $sender) {
            if (is_callable($sender)) {
                $sender = call_user_func($sender);
            }
            if (is_string($sender)) {
                $sender = new $sender();
            }
            if ($sender instanceof \BearFramework\Emails\ISender) {
                if ($sender->send($email)) {
                    if ($this->hasEventListeners('sendEmail')) {
                        $eventDetails = new \BearFramework\Emails\SendEmailEventDetails($email);
                        $this->dispatchEvent('sendEmail', $eventDetails);
                    }
                    return;
                }
            }
        }
        throw new \Exception('No email sender is capable of sending the email provided.');
    }
1125463
public function setEmail($email)
    {
        if (!empty($email) && is_string($email) && ctype_print($email)) {
            $this->email = trim($email);
        }

        return $this;
    }
1219197
public function send(Email $email)
    {
        $message = [
            'html' => $email->message(Email::MESSAGE_HTML),
            'text' => $email->message(Email::MESSAGE_TEXT),
            'subject' => mb_decode_mimeheader($email->getSubject()), // Decode because SendGrid is encoding
            'from' => key($email->getFrom()),
            'fromname' => current($email->getFrom()),
            'to' => [],
            'toname' => [],
            'cc' => [],
            'ccname' => [],
            'bcc' => [],
            'bccname' => [],
            'replyto' => $email->getReplyTo() ? array_values($email->getReplyTo())[0] : key($email->getFrom()),
        ];
        // Add recipients
        $recipients = [
            'to' => $email->getTo(),
            'cc' => $email->getCc(),
            'bcc' => $email->getBcc()
        ];
        foreach ($recipients as $type => $emails) {
            foreach ($emails as $mail => $name) {
                $message[$type][] = $mail;
                $message[$type . 'name'][] = $name;
            }
        }

        // Create a new scoped Http Client
        $this->http = new Client([
            'host' => 'api.sendgrid.com',
            'scheme' => 'https',
            'headers' => [
                'User-Agent' => 'CakePHP SendGrid Plugin'
            ]
        ]);

        $message = $this->_attachments($email, $message);

        return $this->_send($message);
    }
165378
public static function createContact()
    {
        $person = self::getPerson();

        // New person check
        if (isset($person->resourceName)) {
            throw new Exception("You should use newPeron() before create", 500);
        }
        
        return self::getService()->people->createContact($person);
    }
1184989
public function subscriberInfo(string $email) : Collection
    {
        try {
            return $this->api->get('lists/'.$this->id().'/members/'.$this->support->hashEmail($email));
        } catch (\Exception $e) {
            # Email address isn't on this list
            if (str_contains($e->getMessage(), 'Resource Not Found')) {
                throw new EmailAddressNotSubscribed;
            }

            throw $e;
        }
    }
28589
public function setEmail($email)
    {
        $email = is_null($email) ? '' : $email;
        parent::setEmail($email);
        $this->setUsername($email);

        return $this;
    }
1002579
public function create( $username, $password, $email = null ) {
		if ( !is_string( $username ) ) {
			throw new InvalidArgumentException( '$username should be a string' );
		}
		if ( !is_string( $password ) ) {
			throw new InvalidArgumentException( '$password should be a string' );
		}
		if ( !is_string( $email ) && !is_null( $email ) ) {
			throw new InvalidArgumentException( '$email should be a string or null' );
		}

		$params = [
			'createreturnurl' => $this->api->getApiUrl(),
			'createtoken' => $this->api->getToken( 'createaccount' ),
			'username' => $username,
			'password' => $password,
			'retype' => $password,
		];

		if ( !is_null( $email ) ) {
			$params['email'] = $email;
		}

		try {
			$result = $this->api->postRequest( new SimpleRequest( 'createaccount', $params ) );
			return $result['createaccount']['status'] === 'PASS';
		} catch ( UsageException $exception ) {
			// If the above request failed, try again in the old way.
			if ( $exception->getApiCode() === 'noname' ) {
				return $this->createPreOneTwentySeven( $params );
			}
			throw $exception;
		}
	}
784060
public function setFrom($email, $name = '')
    {
        if (empty($email)) {
            throw new MailerException('email is required for setFrom!');
        }

        if (empty($name)) {
            $name = substr($email, 0, strrpos($email, '@'));
        }

        if (is_null($this->from)) {
            $this->from = [$email, $name];
        } else {
            throw new MailerException('Sender has already been set!');
        }

        return $this;
    }
847483
public function setEmail(string $email) : CNabuDataObject
    {
        if ($email === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$email")
            );
        }
        $this->setValue('nb_user_email', $email);
        
        return $this;
    }