[TYPO3-core] Another patch request for t3lib_htmlmail

Michael Stucki michael at typo3.org
Thu Jan 26 13:02:30 CET 2006


Hi Stanislas,

>> 1. As it seems, your charset related fixes are not working yet:
>>
>> +                       // Default charset
>> +               $this->charset = $this->charset ? $this->charset :
>> 'iso-8859-1';
> 
> I think it does. You need to set the charset variable of your instance
> of t3lib_htmlmail to the value you want it to use.

You are right. It works and I was wrong, but there were probably easier ways
to write the above output:

if (!$this->charset) $this->charset = 'iso-8859-1';

Anyway, I think this is solved by my patch already.

>> Since I have a full patch ready for this, please remove the charset
>> related stuff and wait for my next mail.
> 
> Since you are working with a version of dmailer that will not be used in
> the next version of Direct mail, I am afraid that your patch may fail in
> the context of Direct Mail.

OK. I wonder how you will send the mails with that future version? Will you
still use t3lib_htmlmail in the end?

>> 2. I don't like the hostname detection:
>>
>> -               $this->messageid = md5(microtime()).'@domain.tld';
>> +               $localhost = gethostbyaddr('127.0.0.1');
>> +               if (!$localhost || $localhost == '127.0.0.1' ||
>> $localhost == 'localhost') $localhost = md5($TYPO3_CONF_VARS['SYS'
>> ['sitename']).'.TYPO3';
>> +               $this->innerMessageid = md5(microtime()) . '@' .
>> $localhost;
>>
>> Please use the output of php_uname('n') instead.
> 
> What is wrong with the hostname detection? This has been tested on many
> installations for many months now, I would be hesitant to change it at
> this time.

Of course it will work because the value is most likely a unique one.
However, you are not specifiying the true hostname of the mail server, but
a custom string which is additionally md5sum()-ed at the end. Thus, the
output is not self-explaining anymore.

I don't have the RFC right here but think that the hostname part of a
message-ID must be a valid host.

>> Do NOT md5sum it (hostname should be readable).
> 
> Can you guaranty that we will never get any characters that the RFC
> would consider illegal?
> The RFC does not require a hostname of any kind. There is no requirement
> that it should be "readable". It requires a universally unique
> identifier. I think the proposed script is the best bet.

I think the FQDN is unique except when nothing was specified. In that case,
the name was forced to be "localhost" which is not wrong since I don't care
much about webservers in a single-host network... ;-)

Example:
Consider a very random md5sum of microtime():
b026324c6904b2a9cb4b88d6d61c81d1

And consider the MD5sum of the sitename "Dummy" + "TYPO3" (added by you
above):
ae200dd3dca0b03905349a23da92d17d

Now imagine that both servers would send a message in exactly the same
microsecond:

Message-ID on host www.google.ch:
b026324c6904b2a9cb4b88d6d61c81d1 at ae200dd3dca0b03905349a23da92d17d

Message-ID on host www.yahoo.com:
b026324c6904b2a9cb4b88d6d61c81d1 at ae200dd3dca0b03905349a23da92d17d

(After all, it's exactly the same.)

Now again, using the hostname of the system:

Message-ID on host www.google.ch:
b026324c6904b2a9cb4b88d6d61c81d1 at www.google.ch

Message-ID on host www.yahoo.com:
b026324c6904b2a9cb4b88d6d61c81d1 at www.yahoo.com

I think that this combination is not as random as when you appended a
plain-text hostname which is (in a properly configured environment) unique,
even though it's not md5sum()-ed.

>> If the function returns nothing, append "localhost" as
>> default workaround.
> 
> This would not be compliant with the RFC requirements.

Does it hurt in an environment with only one "localhost"?

So there is just the risk that the hostname is properly set up _but_
php_uname('n') doesn't output anything for whatever reasons...

>> You can use this funtion here because technically speaking, the mail is
>> not sent by the Websites hostname but the servers hostname. So this
>> should be correct.
> 
> Any domain registered with the Internet registration authorities will
> do, because we know it will be unique, and this is what is important
> (and this is also why I cannot use localhost as default).

OK. Use whatever you find useful but only if the output of php_uname('n')
was empty or "localhost".

>> 3. Why do you set $this->innerMessageid above? It's not used anywhere
>> else. $this->messageid is also set, that should be enough.
> 
> It is used in setHeaders(). t3lib_dmailer, as well as its replacement
> class in Direct Mail, may modify $this->messageid and may (I should say
> will) do so before the headers are set.

So why don't you add it in t3lib_dmailer instead?

class t3lib_dmailer extends t3lib_htmlmail {
        var $innerMessageid='';

        // wherever you use the messageId for the first time
        function blabla()       {
                $this->innerMessageid=$this->messageid;

                echo "etc.";
        }
}

Regards, michael
-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/



More information about the TYPO3-team-core mailing list