[TYPO3-core] t3lib_utility_mail vs. t3lib_mail?

Ernesto Baschny [cron IT] ernst at cron-it.de
Wed Jan 4 12:24:46 CET 2012


Tolleiv Nietsch schrieb am 04.01.2012 11:39:
> Hi,
> 
> some time ago I suggested a hook for the mail functions in t3lib_div
> (now placed in t3lib_utility_mail) and back then I had put quite some
> effort to have a central place which every mail sent from TYPO3 had to
> pass.
> 
> In the meantime t3lib_mail_* and SwitfMail was introduced in addition to
> that and it seems that the effort was worthless because everything
> handled within t3lib_mail_* bypasses t3lib_utility_mail->mail and
> therefore such mails will leave the system without passing the "old" hook.
> 
> So what I'd like to suggest is to get rid of t3lib_utility_mail or at
> least remove t3lib_utility_mail->mail() in favor of t3lib_mail_* but
> before I put any work into that I'd like to get input for that.

Yes, passing everything to the "buggy" mail() API but through a central
place was a good intermediate solution, but indeed the "way to go" for
sending mails out of TYPO3 is not mail() (and thus not
utility_mail->mail()) but t3lib_mail and it's engines. SwiftMailer *has*
a mail() engine (the default one), but we didn't hack the SwiftMailer
code to make that call our t3lib_utility_mail.

The other way around, the t3lib_utility_mail is hooked by SwiftMailer
(t3lib_mail_SwiftMailerAdapter) to use it's engine when someone calls
legacy t3lib_utility_mail::mail(). But this might be buggy (because it
has to parse the headers and MIME-parts from a ready to send mail and
generate RFC-conformant versions of it) and can be disabled
(substituteOldMailAPI=0 in install tool).

So +1 on deprecating t3lib_utility_mail::mail(). Other methods like
getSystemFrom, getSystemFromName, getSystemFromAddress are still
interesting and can be kept in this utility class.

Another idea would be to add a very simple "simpleMail()" method there
which can be used to simply send "simple mails out" (like notifications):

- ASCII-text body
- Subject
- Array of destination addresses
- From is chosen by the system

So that extensions wanting to just "say something via email" can do it
with one simple line of code. Any further requirements (HTML-body, etc)
the extension developer should create a t3lib_mail object.

Cheers,
Ernesto


More information about the TYPO3-team-core mailing list