Results 1 to 3 of 3

Thread: [SOLVED] Swift_RfcComplianceException not handled by Email

  1. #1
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default [SOLVED] Swift_RfcComplianceException not handled by Email

    I've got my "sendTo()" function is a try block, to trap invalid e-mails, however it still does not catch the exception, even though they match 100%??

    This code is similar to Newsletters.php
    Code:
    ...
    		// Deactivate invalid addresses
    		try
    		{
    			$objEmail->sendTo($arrRecipient);
    		}
    		catch (Swift_RfcComplianceException $e)
    		{
    			$_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
    		}
    
    		// Rejected recipients
    		if ($objEmail->hasFailures())
    		{
    			$_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
    		}
    ...
    with an invalid e-mail like the one below, it does NOT get trapped by the exception. Is it a try block too deep, or something?

    Code:
    Fatal error: Uncaught exception Swift_RfcComplianceException with message Address in mailbox given [wrongtime32431&%#^@] does not comply with RFC 2822, 3.6.2. thrown in system/modules/core/vendor/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php on line 352
    #0 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php(264): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('wrongtime32431&...')
    #1 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php(108): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array)
    #2 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php(65): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array)
    #3 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/SimpleHeaderFactory.php(60): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array)
    #4 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/SimpleHeaderSet.php(70): Swift_Mime_SimpleHeaderFactory->createMailboxHeader('To', Array)
    #5 system/modules/core/vendor/swiftmailer/classes/Swift/Mime/SimpleMessage.php(324): Swift_Mime_SimpleHeaderSet->addMailboxHeader('To', Array)
    #6 system/modules/core/library/Contao/Email.php(426): Swift_Mime_SimpleMessage->setTo(Array)
    #7 system/modules/calendar_invites/classes/EventInvites.php(436): Contao\Email->sendTo('wrongtime32431&...')
    #8 system/modules/calendar_invites/classes/EventInvites.php(202): Contao\EventInvites->sendInvitation(Object(Contao\Email), Object(Contao\Database\Mysql\Result), 'wrongtime32431&...', '    HP Feel the...', 'send(Object(Contao\DC_Table))
    #10 contao/main.php(129): Contao\Backend->getBackendModule('calendar')
    #11 contao/main.php(271): Main->run()
    #12 {main}

  2. #2
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Re: Swift_RfcComplianceException not handled by Email.php

    Might be a namespace issue, try putting a \ infront of the class so it's \Swift_RfcComplianceException. If your code is in the Contao namespace it will be looking for Contao\Swift_RfcComplianceException.

    I don't know if that's the case here because i'm not sure what namespace your code is and and what namespace Swift_RfcComplianceException is in, but I know that when i've tried to catch exceptions before in Contao 3 I had to use \Exception.

  3. #3
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Swift_RfcComplianceException not handled by Email.php

    That was it! Thanks for the help. I guess the Newsletter.php has a bug in it too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •