From ab2b675247b8618a350ca017c24c02873a103f14 Mon Sep 17 00:00:00 2001 From: cubic Date: Mon, 13 Feb 2023 15:13:18 +0800 Subject: [PATCH] fix(email send driver): use Command Utility to run command --- .../service/MessageService/Email/Driver/Mail.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/libraries/service/MessageService/Email/Driver/Mail.php b/application/libraries/service/MessageService/Email/Driver/Mail.php index 8e04536..e461302 100755 --- a/application/libraries/service/MessageService/Email/Driver/Mail.php +++ b/application/libraries/service/MessageService/Email/Driver/Mail.php @@ -2,6 +2,7 @@ namespace service\MessageService\Email\Driver; use service\Utility\Logger; +use service\Utility\Command; class Mail { static function send (string $to, string $title, string $body) @@ -13,7 +14,17 @@ class Mail { $from = YAML_EMAIL_NAME . '<' . YAML_EMAIL_FROM . '>'; - $result = exec("export LANG=en_US.UTF-8 && echo -e '{$body}' | mail -r '{$from}' -s '{$title}' '{$to}' > /dev/null &"); + // $result = exec("export LANG=en_US.UTF-8 && echo -e '{$body}' | mail -r '{$from}' -s '{$title}' '{$to}' > /dev/null &"); + + $result = []; + Command::run([ + 'echo', '-e', Command::wrapArgument($body), '|', + 'mail', '-r', Command::wrapArgument($from), + '-s', Command::wrapArgument($title), Command::wrapArgument($to), + '> /dev/null &' + ], $result); + + $result = implode('', $result); Logger::Log( 'from:' . $from . ' Sent result:' . json_encode($result),