tina4 routing code example

Example: tina4 sending an email

//This exmaple requires PHP mailer to be installed
//Also requires the openssl PHP extension

//Configure settings
$settings = new \Tina4\MessengerSettings(true);
$settings->smtpUsername = "smtp username";
$settings->smtpPassword = "smtp password";
$settings->smtpServer = "smtp.server.com";

//Add recipients
$recipients[] = ["name" => "Tester Person", "email" => "[email protected]"];

//expects a twig template in templates/messenger/message.twig
(new \Tina4\Messenger($settings))->sendEmail($recipients, //Recipients
                                             "Test Email", //Subject
                                             ["template" => "message.twig", 
                                              "data" => ["firstName" => "Test", "message" => "Hello World!"]
                                             ],
                                             "Test", //From name
                                             "[email protected]", //From email address
                                             null, //attachments
                                             null //Bcc - same form as recipients
                                            );

Tags:

Php Example