php - PHPMailer Invalid address -


i want send mail phpmailer. use code, got error :

invalid address: example@gmail.com

(i use fake addresses stackoverflow. use real address in real code.)

<?php      $from = "my name";     $mail = "example@gmail.com";      require_once('./class.phpmailer.php');      $bodytext = "     <html>     <head>     <title>title</title>     </head>     <body>     <h1 style='text-align:center'>some text</h1>     <p>more text. here's name : $from</p>     </body>     </html>     ";     try {         $email = new phpmailer(true);         $email->from      = 'webmaster@mysite.com';         $email->fromname  = 'webmaster';         $email->ishtml(true);         $email->subject   = 'subject';         $email->body      = $bodytext;         $email->addaddress( $mail, "name" );         $email->addreplyto($mail,"name");          // $file_to_attach = $filepath;          // $email->addattachment( $file_to_attach , 'constat.pdf' );          $email->send();         } catch (exception $e) {         echo $e->getmessage();     }     // var_dump($email); ?> 

sice there smtp server running, don't have configure it, , php function mail working.

how can fix error ?

well. actually, there problem regular expression checking if mail address valid when pattern selected pcre8. changed to

/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 

and it's working now.

thanks @synchro.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -