views:

465

answers:

2

hi

I am using SwiftMailer for sending mails and if I try to use dummy email address, for example if I type in "asdf" in email address, I get this uncaught exception.

   Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 
'Address in mailbox given [asdf] does not comply with RFC 2822,

I am not very experienced in OO .. so not sure how to handle this? Actually I just want it to fail if the email address is not valid but it shouldnt throw the fatal error message. Any suggestions?

Thanks.

+2  A: 

You need to catch the exception, like this

try
{
    // Your code to send the email
}
catch (Swift_RfcComplianceException $e)
{
    print('Email address not valid:' . $e->getMessage());
}

This isn't an OO thing, it's an exceptions thing.

Greg
you right there .. thanks it worked.
Wbdvlpr
A: 

I think that it means that the given email address doesn't respect the email adressess standards.

mck89
sorry i didn't read the last part of the question :)
mck89
no worries
Wbdvlpr