Swift_Validate::email PHP Method

email() public static method

Checks if an e-mail address matches the current grammars.
public static email ( string $email ) : boolean
$email string
return boolean
    public static function email($email)
    {
        if (self::$grammar === null) {
            self::$grammar = Swift_DependencyContainer::getInstance()->lookup('mime.grammar');
        }
        return (bool) preg_match('/^' . self::$grammar->getDefinition('addr-spec') . '$/D', $email);
    }

Usage Example

Ejemplo n.º 1
0
 static function sendemail($to, $subject, $message2, $ar = array())
 {
     include WRA_Path . '/modules/swiftmailer/swift_required.php';
     WRA::debug($to);
     // die();
     if (!Swift_Validate::email($to)) {
         //if email is not valid
         //do something, skip them or log them
         WRA::debug("invalid email");
         WRA::debug($to);
         die;
     }
     $message = Swift_Message::newInstance()->setSubject($subject)->setFrom(WRA_CONF::$smtpfrom)->setTo(array($to))->setBody($message2, 'text/html', 'utf-8');
     for ($i = 0; $i < count($ar); $i++) {
     }
     $transporter = Swift_SmtpTransport::newInstance(WRA_CONF::$smtpserver, WRA_CONF::$smtpport, '')->setUsername(WRA_CONF::$smtpuser)->setPassword(WRA_CONF::$smtppassword);
     $mailer = Swift_Mailer::newInstance($transporter);
     try {
         $result = $mailer->send($message);
     } catch (Exception $e) {
         WRA::logit($e->getMessage(), 'message');
         // echo   $e->getMessage(), "\n";
     }
     return $result;
 }
All Usage Examples Of Swift_Validate::email
Swift_Validate