[TYPO3-core] RFC #15998: Create a new API based on SwiftMailer to replace t3lib_htmlmail
Ernesto Baschny [cron IT]
ernst at cron-it.de
Sun Oct 17 12:02:23 CEST 2010
Am 17.10.2010 11:00, schrieb Martin Kutschker:
> Am 16.10.2010 21:46, schrieb Ernesto Baschny [cron IT]:
>>
>> This is also meant to replace all direct calls to "mail()" and also "t3lib_utility_Mail" in future,
>> because of its flexibilty in sending mails.
>
> I would split the composition of mails and the sending of mails. Both tasks are related, but
> distinct. IMHO it makes sense to have a MIME composition class that let's you create a message,
> which - tata - is then passed to a news gateway.
To complete the answer: To do a "NNTP" transport, I would suggest the
following way:
Create a:
tx_nntpTransport implements Swift_Transport
You compose your message using t3lib_mail_message:
$message = t3lib_div::makeInstance('t3lib_mail_message');
$message->setFrom(array($email => $name));
$message->setTo(array($email => $name));
$message->setSubject($subject);
$message->setBody($body);
Add some other Text header:
$message->getHeaders()->addTextHeader('Newsgroup', 'typo3.dev');
You then initializes your NNTP transport...
$transport = tx_nntpTransport::tx_nntpTransport();
$transport->setNntpServer('lists.typo3.org');
... And start the "engine" to send the message using that transport:
$engine = t3lib_div::makeInstance('t3lib_mail_mailer', $transport);
$engine->send($message);
Cool, isn't it?
By doing that example I just noticed that I forgot to add the $transport
parameter to the constructor of the t3lib_mail_mailer. I committed that
follow-up to rev 9124.
Cheers,
Ernesto
More information about the TYPO3-team-core
mailing list