in reply to Calling a PHP function from within Perl
Probably your best bet is to write a helper script called something like sendMail-cli.php something like this:
<?php require_once 'sendMail.php'; extract(json_decode(file_get_contents('php://stdin'))); sendMail($fromName, $fromEmail, $to, $cc, $bcc, $subject, $messageHtml +, $messageText);
And then from Perl, you can pass data to that:
use JSON; my %mail = ( fromName => 'Alice', fromEmail => 'alice@example.com', to => 'bob@example.net', cc => 'carol@example.net', bcc => 'dave@example.org', subject => 'Test message', messageHtml => '<p>Test</p>', messageText => "Test\n", ); open my $sm, '|php sendMail-cli.php' or die 'could not open pipe to se +nd mail'; print {$sm} encode_json(\%mail); close $sm;
There are probably nicer ways to do it, but that's quick and easy.
Code is untested, but should give you a general idea.
(For bonus points, make sure that sendMail-cli.php cannot be called directly via your webserver, to avoid creating a spam gateway.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Calling a PHP function from within Perl
by DaisyLou (Sexton) on Jul 28, 2019 at 03:49 UTC | |
by tobyink (Canon) on Jul 28, 2019 at 11:45 UTC | |
by DaisyLou (Sexton) on Jul 29, 2019 at 19:38 UTC | |
by tobyink (Canon) on Aug 02, 2019 at 10:56 UTC |