Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2017-04-13 11:58:36
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
textpattern's mail sending mechanism
Hi,
I’ve been away from txp for years, but have recently put together a quick blog style site.
My live installation is unable to send new user emails or password resets as my host doesn’t support php mail(). I have the same problem with the latest beta of zem contact.
Is there anyway I can modify textpattern to send mail as an smtp authenticated user? I’d rather do that than move hosts.
Kind regards,
Mike
Offline
Re: textpattern's mail sending mechanism
There’s good news and bad news. Good news: you can do it without much hacking. Bad news: it’ll require some coding.
Everything in 4.6.0+ to do with mail delivery has been centralised. So look in vendors/Textpattern/Mail
for all things maily. If you look in the Adapter
directory you’ll find a concrete implementation of a Mail
class that uses mail()
.
So, in theory, all you need to do is copy that file, make a new adapter called, e.g. SMTPMail
, and alter the various functions in there to support SMTP, primarily the send()
function I would guess.
You then need to hook this into Txp itself. To do that (I’ve never done it, only guessing here) you’ll need a new Composable object. So look at the Compose
class. I would assume you’d copy that and make a new one called SMTPCompose
and make it point to your SMTPMail
Adapter.
Once that’s done, look in txplib_misc.php
for the Txpmail()
function. Change:
$message = Txp::get('Textpattern\Mail\Compose')
to:
$message = Txp::get('Textpattern\Mail\SMTPCompose')
and you should be done.
Ideally, we could do with making this a bit more open so that (e.g.) a plugin could hop in and provide this functionality. The new ZCR allows this, but it’ll only help you for public-side mailings.
There are people around who can probably help you get this going (Ruud? Oleg? makss) and, when you do, we might look into making it simpler for future versions.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#3 2017-04-13 13:47:34
- mmelon
- Member
- Registered: 2006-03-02
- Posts: 95
Re: textpattern's mail sending mechanism
thanks for the advice. I’ll have a go
Offline