本文整理汇总了PHP中Email::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::validate方法的具体用法?PHP Email::validate怎么用?PHP Email::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::validate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldUseEmailValidatorWhenDefined
public function testShouldUseEmailValidatorWhenDefined()
{
$this->resetClassExists();
$input = 'example@example.com';
$emailValidator = $this->getEmailValidatorMock();
$emailValidator->expects($this->once())->method('isValid')->with($input)->will($this->returnValue(true));
$rule = new Email($emailValidator);
$this->assertTrue($rule->validate($input));
}
示例2: validate
/**
*
* @link http://www.linuxjournal.com/article/9585?page=0,3
* @param string $value
* @return boolean
*/
public function validate($value)
{
if (!parent::validate($value)) {
return false;
}
$host = substr(strstr($check[0], '@'), 1) . ".";
if (function_exists('getmxrr')) {
$tmp = null;
if (getmxrr($host, $tmp)) {
return true;
}
// this will catch dns that are not mx.
if (checkdnsrr($host, 'ANY')) {
return true;
}
}
return $host != gethostbyname($host);
}
示例3: send
/**
* @abstract A wrapper to the mail function. All parameters are the same accept for $headers. The $to address will be validated
* via Email::validate.
*
* @param mixed $to An email address which to send this email to. Can either be a string address or an EmailAddress object.
* @param string $subject The subject of the email.
* @param string $message The message of the email.
* @param mixed $headers Optional. If a string, then it is passed directly to mail() as it is; otherwise, it is passed to Email::headers()
* (default: false).
* @return bool True if the mail was sent successfully; otherwise, false.
*
* @see EmailAddress()
* @see Email::validate()
* @see Email::headers()
*/
public static function send($to, $subject, $body, $replyTo = false)
{
if (!Email::validate($to)) {
return false;
}
$mail = self::newMailer();
$mail->AddAddress($to);
$mail->From = MAIL_SENDER_NOREPLY;
$mail->FromName = MAIL_SENDER_NOREPLY_NAME;
$mail->Subject = $subject;
$mail->Body = $body;
if ($replyTo) {
if (!is_array($replyTo)) {
$replyTo = array($replyTo, '');
}
$mail->AddReplyTo($replyTo[0], $replyTo[1]);
$mail->From = $replyTo[0];
$mail->FromName = $replyTo[1];
}
return $mail->Send();
}
示例4: test_invalid_emails_should_fail_validation
/**
* @dataProvider providerForInvalidEmail
* @expectedException Respect\Validation\Exceptions\EmailException
*/
public function test_invalid_emails_should_fail_validation($invalidEmail)
{
$validator = new Email();
$this->assertFalse($validator->validate($invalidEmail));
$this->assertFalse($validator->assert($invalidEmail));
}
示例5: create
public static function create($params)
{
$user = new User();
$user->username = $params['user'];
$user->credential = hasher($params['password']);
$user->email = $params['email'];
$user->date_joined = date("Y-m-d H:i:s");
$user->ip = $_SERVER['REMOTE_ADDR'];
$user->validation = md5(time() . rand());
$user->validated = 0;
$user->member_id = $params['member_id'];
$user->date_joined = date('Y-m-d H:i:s');
$user->role = 0;
$user->last_logged = 0;
$user->last_seen = 0;
$user->developer = 0;
$user->save();
Email::validate($user);
}
示例6: testFilter
/**
* @dataProvider provideTestFilter
*/
public function testFilter($options, $raw, $filtered, $valid)
{
$int = new Email($options);
$this->assertEquals($filtered, $int->filter($raw));
$this->assertEquals($valid, $int->validate($raw));
}
示例7: testValidateValidEmail
public function testValidateValidEmail()
{
$email = new Email('as@asd.com', 'as', 'asde');
$this->assertTrue($email->validate());
}
示例8: testIsGettingErrorMessage
public function testIsGettingErrorMessage()
{
$constraint = new Email();
$this->assertFalse($constraint->validate('foobar.com'));
$this->assertEquals('[field] Invalid email format', $constraint->getErrorMessage('field'));
}