[TYPO3-core] RFC #16591 The new Swift Mailer should be used by TYPO3 for sending all kinds of mail

Ernesto Baschny [cron IT] ernst at cron-it.de
Mon Nov 29 22:48:24 CET 2010


Jigal van Hemert schrieb am 28.11.2010 23:37:

> This is a SVN patch request.
> 
> Type: Bugfix / Clean up
> 
> BT reference: http://bugs.typo3.org/view.php?id=16591
> 
> Branches: trunk
> 
> Problem:
> Currently t3lib_utility_Mail::mail() is used by various core functions
> to send emails. The new Swift Mailer classes provide more transport
> mechanisms to send mails (e.g. SMTP / sendmail / mail).
> 
> Solution:
> A hook subscriber for a hook in t3lib_utility_Mail::mail() can be used
> to let the core send mails via Swift Mailer without modifications to
> existing code.
> 
> How to test:
> Configure SMTP for Swift Mailer and see that with the path system mails
> (such as BE login notifications) are sent via that SMTP connection.
> 
> Notes:
> This idea was discussed in the v4 list and the functionality was
> approved by both RMs.

Cool stuff, Jigal!

I just tested it, and as a by-product I created a "mbox" transport
(which just writes every mail to a file, will have that RFC ready in a
minute).

I then removed the big "try { .. } catch" block around the whole sending
code, because you are not doing anything except throwing yet another
exception in that case. To ease debugging if something wents wrong it is
best not to catch the Exception but just let it be thrown as-is (you'll
get the exact Swift Exception name in our DebugHandler).

Then I tried using a frontend "old-school" htmlform to send me an
e-mail. This was then choking:

Swift_RfcComplianceException thrown in file
/www/shared/TYPO3core/trunk/typo3/contrib/swiftmailer/classes/Swift/Mime/Headers/IdentificationHeader.php
in line 118.

Reason was that our ID headers already include a "<>" around the ID, and
the "addIdHeader()" method expects that without the enclosing <>. So
doing a trim by "<>" was enough to get it working.

Then it worked like a charm, and my whole TYPO3 installation was saving
the generated mails to a file instead of sending them through mail()
(tested in the FE with mailforms and in the backend with a scheduler
test task). Which is a very cool tool to debug future mail sending
extensions!

+1 on reading and testing v2 attached to this mail.

Cheers,
Ernesto
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 16591-v2.patch
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101129/af2ebe92/attachment.txt>


More information about the TYPO3-team-core mailing list