Validate an e-mail address

If you want to validate an e-mail address in your code and you will use JMAIL anyway, you can use the function from its parent class phpmailer.

$mail 	=& JFactory::getMailer();
if (!$mail->ValidateAddress($mailaddress)) echo 'Invalid';

This is implicitly done for every JMAIL function that sets an address (such as addRecipient, addBCC, ..) and though there are other potential errors besides address validating, it most probably is something you want catch too.

$mail 	=& JFactory::getMailer();
if ($mail->addRecipient($mailaddress)->IsError()) echo 'Invalid';