What is the recommended way for sending emails from PHP code, using the template system. I'm working on a customisation where I'll have a cron job checking for certain conditions in the database on a regular basis and I'd like to be able to send emails to customers from the PHP code. Is it possible to use the email template functionality for this? Can I write the code in PHP to check the condition and then make an API call to the BD platform to send the email?
Did you ever manage to achieve this?
Yes, I built my own email and templating system.
I can help you with this if you like.
I'm thinking of trying to writer something or even use the email engine from my current website. Any guidance you have is appreciated.
Hi, what's your email address? I'll drop you a PM.
Hi Jonny - you can contact me at firstname.lastname@example.org
I think that most script sending templates can be found. I will only say that when sending to multiple recipients, it's best to use the Bcc header: which sends a copy of the message to the specified email (taking from my college homework):
<?php $to = "email@example.com"; $subject = "Checking the sending letters"; $message = "Hi! Mail robot"; // message text $mailheaders = "Content-type:text/plain;charset=utf-8"; $mailheaders .= "From: SiteRobot <firstname.lastname@example.org>"; $mailheaders .= "Reply-To: email@example.com"; $mailheaders .= "Bcc: firstname.lastname@example.org"; $mailheaders .= "Bcc: email@example.com"; $mailheaders .= "Bcc: firstname.lastname@example.org"; mail($to, $subject, $message, $mailheaders); // send letter ?>