Page 1 of 1
[SOLVED] Swift's max length for subject - what is the max?
Posted: Fri Apr 13, 2007 6:12 am
by Oren
Ok, so I have something along these lines (just like the example on Swift's site):
Code: Select all
$sender = new Swift_Address($email, $name);
// Create the message to send
$message = new Swift_Message($subject);
Now what is the max length for $name before Swift steps in and do any modifications to the name?
And the same question with $subject...
Thanks.
Posted: Fri Apr 13, 2007 6:19 am
by Chris Corbyn
76 chars per line (78 including the \r\n).
So we now need to do a bit of maths and it actually gets a bit confusing.
"To: " = 4 chars so we now have 72 chars on the first line + (76-1) chars for every other line. Why -1? Because we need LWSP (Linear Whitespace) at the start of each sucessive line in a wrapped header.
$name also has space wasted by the <email@address> part so you can deduct that too. It gets even more complex once Swift detects non-us-ascii characters in the header since it then needs to encode the header which adds even more information on the line (=?Q?windows-874? .... ?=) Swift should never break what you specify though. When it arrives at the mail client it should look like what you typed.
Why do you ask?
There's already a bug been posted about $subject being broken if it's too long. I'm fixing that - it's a trivial, minor bug.
Posted: Fri Apr 13, 2007 8:21 am
by Oren
d11wtq wrote:There's already a bug been posted about $subject being broken if it's too long. I'm fixing that - it's a trivial, minor bug.
That's pretty much why I asked, the problem is that now I'm even more confused
You showed me all the math and then said:
d11wtq wrote:When it arrives at the mail client it should look like what you typed
So in my contact form, do I need to put any limitations on the length (or any other limitations) of the name/subject fields?
By that I mean that I want to see in my mail box exactly
what I entered.
what I entered = what the user sent after I did my own filtering according to what I decided to be valid.
P.S I haven't had a chance to test it by myself since my FTP access isn't working for some reason and I don't have a mail server on my local machine, so that's why I'm asking all kind of questions instead of trying by myself.
Anyway, thanks for the help

Posted: Fri Apr 13, 2007 9:37 am
by Chris Corbyn
You don't need to put any limits on there no. There is no maximum subject length as far as you are concerned
PS: To fix the known bug (the bug simply add a space where there shouldn't be one) before I make another release just open up Swift_Message_Encoder file, find the method header7BitEncode() and change:
Code: Select all
$ret .= wordwrap($data, $chunk-2, $le, true);
//to
$ret .= wordwrap($data, $chunk-2, $le);
Posted: Fri Apr 13, 2007 10:20 am
by Oren
Ok, thanks. When are you going to make the next release? This is not urgent so I can wait just in case you'll make more changes...
Posted: Fri Apr 13, 2007 11:11 am
by Chris Corbyn
Oren wrote:Ok, thanks. When are you going to make the next release? This is not urgent so I can wait just in case you'll make more changes...
I make releases roughly once every week. I'd make new releases every day or two but people start to get annoyed with me when I do that

If you want the very latest (as in, my version) then use subversion.