Page 1 of 1
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 8:29 am
by Chris Corbyn
Any e-mail address that is not RFC compliant isn't going to work.
But to catch the error, you just need to pre-empt this possibility and make use of the try/catch structure:
Code: Select all
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
try {
$message->setTo('nocrfc');
} catch (Swift_RfcComplianceException $e) {
//Error handled here
}
//Execution continues here...
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 9:16 am
by roxor
Thanks for the quick response Chris
I will use than exception handling, to log also non RFC email addresses.
Swift rules. GREAT WORK, CONGRATULATIONS

I hope there will be soon a nice tutorial for newsletter sending and a commercial version of Swift.
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 4:03 pm
by Chris Corbyn
roxor wrote:Swift rules. GREAT WORK, CONGRATULATIONS

I hope there will be soon a nice tutorial for newsletter sending and a commercial version of Swift.
Thanks
Tutorials coming soon in the documentation. There will be general "how to" topics that are quick examples, then there will be a section that talks about common usage patterns and best practices, finally the documentation will end with a walk-through of building (something like) a newsletter system in (probably) Zend Framework using Swift Mailer.
In terms of a commercial version, we're not going to do it. We're just going to make all of these commercial features available in the free version and hope people donate enough to make it worth while

We have some plans for ways to achieve that.
You'll already see a short list of additions planned for 4.1.x:
http://swiftmailer.lighthouseapp.com/pr ... es/current
More will be added however (possibly VERP and PIPELINING).
Tickets #64, #65 and #67 are all things people have asked for lots.
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 4:23 pm
by Talisto
Chris Corbyn wrote:Any e-mail address that is not RFC compliant isn't going to work.
But to catch the error, you just need to pre-empt this possibility and make use of the try/catch structure:
...
Is there a function we can call to check an email address for RFC compliance before sending it to the setTo() function? The exception catching works well if there's only one address being passed to setTo(), but it's much harder to handle with an array of many addresses where one (or more) address fails the check, which fails the whole batch. I'm assuming the best action is for me to check the addresses in the array before passing them to setTo(), but I'm not quite sure what the process is for that.
Also, is there a way to retrieve which email address caused the exception, without attempting to parse it out of the error message? I'm using a substr() search for the square-brackets in the error message but that seems a bit kludgy.
Thanks!!
Matt
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 4:40 pm
by Chris Corbyn
I'll add an addTo() and addCc(), addBcc() etc methods, then you'll be able to figure it out. Swift's error checking is using the actual grammars given in RFC 2822 so it's very bright.
For now, you can do something like this (funny how these usability issues show up *after* a lengthy beta

):
Code: Select all
foreach ($addresses as $address) {
try {
$message->setTo(array_merge((array) $message->getTo(), (array) $address));
} catch (Swift_RfcComplianceException $e) {
//$address is not valid, but all other addresses remain added
}
}
You shouldn't have to write code like that in the long run though so I'll put the logic in Swift_Message itself via addTo() methods.
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 4:52 pm
by Chris Corbyn
This will be done today:
http://swiftmailer.lighthouseapp.com/pr ... me_message
Basically you'll be able to do:
Code: Select all
$message->addTo('joe@bloggs.com', 'Joe Bloggs');
And the same for Cc, Bcc, From, ReplyTo.
I'll also add the convenience of the second parameter for $name to setTo() and friends. It will simply be an ignored parameter if an array is passed in the first parameter. So this will work:
Code: Select all
$message->setTo('joe@bloggs.com', 'Joe Bloggs'); //Overwrite any existing To: addresses
But the second parameter here will be ignored (silently):
Code: Select all
$message->setTo(array('joe@bloggs.com' => 'Joe Bloggs', 'john@doe.com'), 'Name not used');
Re: Problems with non RFC emails Swift 4
Posted: Thu Mar 12, 2009 5:28 pm
by Talisto
Chris Corbyn wrote:I'll add an addTo() and addCc(), addBcc() etc methods, then you'll be able to figure it out. Swift's error checking is using the actual grammars given in RFC 2822 so it's very bright.
For now, you can do something like this (funny how these usability issues show up *after* a lengthy beta

):
Haha, sorry, I didn't realize there was a beta happening 'till I saw the news of the 4.0.0 release

I'll do my best to help out more in the future, though!
The addTo() function will help immensely, thanks!!
Matt
Re: Problems with non RFC emails Swift 4
Posted: Fri Mar 13, 2009 9:13 pm
by Chris Corbyn
http://swiftmailer.org/downloads/get/Swift-4.0.2.tar.gz
Has the addFrom(), addReplyTo(), addTo(), addCc(), addBcc() methods mentioned above.
Allows ($address, $name) to be passed to setSender(), setFrom(), setReplyTo(), setTo(), setCc() and setBcc()
Code: Select all
$message->setTo('address@domain.org', 'Some Name');
The original behaviour of accepting associative arrays still works.
Re: Problems with non RFC emails Swift 4
Posted: Fri May 28, 2010 5:31 am
by gnutix
Hello,
I use Swift-4.0.6.
I need to send a huge amount of emails and I wanted to know if there is a way to desactivate this verification ?
My application still check the emails format at client modification and import, so this dubbled check made the sending process slower for nuts.
Another few things...
- Is there a way to set the "X-Mailer" header ?
- What is the way to desactivate logging ?
Thank you for your answer.
Cordially, gnutix.