no message
This commit is contained in:
parent
389478cb61
commit
e7bea82d71
@ -89,6 +89,8 @@ $oHttp->aData['message']['text'] = '\/coupon#del 11';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/user#limit 10';
|
||||
|
||||
$oHttp->aData['message']['text'] = '/mail#tmp';
|
||||
|
||||
//$oHttp->aData['message']['text'] = '\/coupon#findById 3';
|
||||
|
||||
|
||||
|
||||
@ -82,8 +82,10 @@ final class TestController extends BaseController
|
||||
public function test2()
|
||||
{
|
||||
$oCron = new CronService();
|
||||
$oCron->processEmailQueue();
|
||||
|
||||
// $oCron->expirePaidUserAccount();
|
||||
$oCron->expireFreeUserAccount();
|
||||
// $oCron->expireFreeUserAccount();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -32,4 +32,15 @@ final class EmailQueue extends Model
|
||||
$this->array = json_encode($array);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function add_bulk($to, $subject, $template, $array): void
|
||||
{
|
||||
$this->to_email = $to;
|
||||
$this->subject = $subject;
|
||||
$this->template = $template;
|
||||
$this->time = time();
|
||||
$this->array = json_encode($array);
|
||||
$this->type = "bulk";
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,12 +452,23 @@ final class Cron
|
||||
|
||||
if (Tools::isEmail($email_queue['to_email'])) {
|
||||
try {
|
||||
Mail::send(
|
||||
$email_queue['to_email'],
|
||||
$email_queue['subject'],
|
||||
$email_queue['template'],
|
||||
json_decode($email_queue['array'])
|
||||
);
|
||||
|
||||
if (isset($email_queue['type']) && $email_queue['type'] == "bulk") {
|
||||
Mail::send_bulk(
|
||||
$email_queue['to_email'],
|
||||
$email_queue['subject'],
|
||||
$email_queue['template'],
|
||||
json_decode($email_queue['array'])
|
||||
);
|
||||
} else {
|
||||
Mail::send(
|
||||
$email_queue['to_email'],
|
||||
$email_queue['subject'],
|
||||
$email_queue['template'],
|
||||
json_decode($email_queue['array'])
|
||||
);
|
||||
}
|
||||
|
||||
} catch (Exception|ClientExceptionInterface $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ use App\Services\Mail\Postal;
|
||||
use App\Services\Mail\SendGrid;
|
||||
use App\Services\Mail\Ses;
|
||||
use App\Services\Mail\Smtp;
|
||||
use App\Services\Mail\Smtp_bulk;
|
||||
use Exception;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Smarty\Smarty;
|
||||
@ -64,4 +65,11 @@ final class Mail
|
||||
|
||||
self::getClient()->send($to, $subject, $body);
|
||||
}
|
||||
|
||||
public static function send_bulk($to, $subject, $template, $array = []): void
|
||||
{
|
||||
$body = self::genHtml($template, $array);
|
||||
|
||||
new Smtp_bulk()->send($to, $subject, $body);
|
||||
}
|
||||
}
|
||||
|
||||
60
src/Services/Mail/Smtp_bulk.php
Executable file
60
src/Services/Mail/Smtp_bulk.php
Executable file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Mail;
|
||||
|
||||
use App\Models\Config;
|
||||
use Exception;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
final class Smtp_bulk extends Base
|
||||
{
|
||||
private PHPMailer $mail;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$configs = Config::getClass('email');
|
||||
$configs['smtp_username'] = "gemcode.bulk@gmail.com";
|
||||
$configs['smtp_password'] = "bfawienpxczjsytb";
|
||||
$configs['smtp_sender'] = "gemcode.bulk@gmail.com";
|
||||
|
||||
$mail = new PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $configs['smtp_host'];
|
||||
$mail->Port = $configs['smtp_port'];
|
||||
$mail->SMTPAuth = ! ($configs['smtp_username'] === '' && $configs['smtp_password'] === '');
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->Username = $configs['smtp_username'];
|
||||
$mail->Password = $configs['smtp_password'];
|
||||
$mail->setFrom($configs['smtp_sender'], $configs['smtp_name']);
|
||||
|
||||
if ($configs['smtp_ssl']) {
|
||||
$mail->SMTPSecure = ($configs['smtp_port'] === '587' ? 'tls' : 'ssl');
|
||||
}
|
||||
|
||||
if ($configs['smtp_bbc'] !== '') {
|
||||
$mail->addBCC($configs['smtp_bbc']);
|
||||
}
|
||||
var_dump($configs);
|
||||
exit;
|
||||
$this->mail = $mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send($to, $subject, $body): void
|
||||
{
|
||||
$mail = $this->mail;
|
||||
$mail->addAddress($to); // Add a recipient
|
||||
$mail->isHTML();
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
|
||||
$mail->send();
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
//declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Tg\Hook\Mod;
|
||||
|
||||
//use App\Models\Zhuanfas;
|
||||
//use App\Utils\Tools;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\EmailQueue;
|
||||
use function str_replace;
|
||||
use function strip_tags;
|
||||
|
||||
final class Email
|
||||
{
|
||||
|
||||
public function tmp()
|
||||
{
|
||||
$subject = "福云 - 重要通知:域名地址变更!";
|
||||
|
||||
|
||||
|
||||
$text = "<br>主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多一个u)。";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$text
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
// $users = (new User())->where('class', '>=', 0)
|
||||
// ->get();
|
||||
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
(new EmailQueue())->add(
|
||||
$user->email,
|
||||
$subject,
|
||||
'war.tpl',
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return "应该发送成功了";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
121
src/Services/Tg/Hook/Mod/Mail.php
Normal file
121
src/Services/Tg/Hook/Mod/Mail.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
//declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Tg\Hook\Mod;
|
||||
|
||||
//use App\Models\Zhuanfas;
|
||||
//use App\Utils\Tools;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\EmailQueue;
|
||||
use function str_replace;
|
||||
use function strip_tags;
|
||||
|
||||
use App\Models\Config;
|
||||
use App\Services\Mail\AlibabaCloud;
|
||||
use App\Services\Mail\Mailchimp;
|
||||
use App\Services\Mail\Mailgun;
|
||||
use App\Services\Mail\NullMail;
|
||||
use App\Services\Mail\Postal;
|
||||
use App\Services\Mail\SendGrid;
|
||||
use App\Services\Mail\Ses;
|
||||
use App\Services\Mail\Smtp;
|
||||
use Exception;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Smarty\Smarty;
|
||||
|
||||
final class Mail
|
||||
{
|
||||
|
||||
public function tmp()
|
||||
{
|
||||
$subject = "福云 - 重要通知:域名地址变更!";
|
||||
|
||||
|
||||
|
||||
$text = "<br>主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多一个u)。";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$text
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
// $users = (new User())->where('class', '>=', 0)
|
||||
// ->get();
|
||||
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
(new EmailQueue())->add_bulk(
|
||||
$user->email,
|
||||
$subject,
|
||||
'war.tpl',
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return "应该发送成功了";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function tmp2()
|
||||
{
|
||||
$subject = "福云 - 重要通知:域名地址变更!";
|
||||
|
||||
|
||||
|
||||
$text = "<br>主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多一个u)。";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$text
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
// $users = (new User())->where('class', '>=', 0)
|
||||
// ->get();
|
||||
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
(new EmailQueue())->add(
|
||||
$user->email,
|
||||
$subject,
|
||||
'war.tpl',
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return "应该发送成功了";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user