Addresses are converted to lowercase
Posted: Fri Jan 18, 2008 7:33 pm
Hi there, first off:
Swift Mailer Version 3.3.2
PHP 5.2.0
I ran into a problem today with an email address that had mixed-case in the local-part (to the left of the @). The problem was actually caused by my custom Decorator class, because it was indexing the substitutions with the email address, which had mixed-case. But the Swift_RecipientList object's addresses is indexed by an address that has been passed through strtolower(). Therefore the two indexes didn't match up. No big deal though, that was easy to fix. I just put a strtolower() in my Decorator code so it'd match up.
But, then I sent out the email to this troublesome recipient and it got bounced back. joe.smith@pickyserver.com did not work. But Joe.Smith@pickyserver.com DID! This email server is for a large government-operated utility, so it's not some random hackish email server. Apparently some email servers DO care about case, since it IS just a local account name.
RFC2822 (Internet Message Format) includes no specifications about case sensitivity.
RFC821 (SMTP) seems to implies mixed-case local-parts should be allowed:
I've made this change in my version, and all works fine. I'd recommend this make it to the next version as well. Or perhaps you'd prefer to just strtolower() the domain/host name and leave the local-part untouched.
Cheers,
Dave
Swift Mailer Version 3.3.2
PHP 5.2.0
I ran into a problem today with an email address that had mixed-case in the local-part (to the left of the @). The problem was actually caused by my custom Decorator class, because it was indexing the substitutions with the email address, which had mixed-case. But the Swift_RecipientList object's addresses is indexed by an address that has been passed through strtolower(). Therefore the two indexes didn't match up. No big deal though, that was easy to fix. I just put a strtolower() in my Decorator code so it'd match up.
But, then I sent out the email to this troublesome recipient and it got bounced back. joe.smith@pickyserver.com did not work. But Joe.Smith@pickyserver.com DID! This email server is for a large government-operated utility, so it's not some random hackish email server. Apparently some email servers DO care about case, since it IS just a local account name.
RFC2822 (Internet Message Format) includes no specifications about case sensitivity.
RFC821 (SMTP) seems to implies mixed-case local-parts should be allowed:
Luckily the fix for this is quite easy. Simply remove all the calls to strtolower() from lib/Swift/RecipientList.phpCommands and replies are not case sensitive. That is, a command or
reply word may be upper case, lower case, or any mixture of upper and
lower case. Note that this is not true of mailbox user names. For
some hosts the user name is case sensitive, and SMTP implementations
must take care to preserve the case of user names as they appear in
mailbox arguments. Host names are not case sensitive.
I've made this change in my version, and all works fine. I'd recommend this make it to the next version as well. Or perhaps you'd prefer to just strtolower() the domain/host name and leave the local-part untouched.
Cheers,
Dave