Commit d58e92e2 authored by hangjun83's avatar hangjun83

财务开票模块更新

parent c9179618
......@@ -531,7 +531,7 @@ class InvoiceService
$message .= "<a href=".$downloadUrl."电子发票下载地址</a>";
$this->mailService->sendMail($title, 'hangjun@rhawn.cn',$message);
$this->mailService->sendMailToHtml($title, 'hangjun@rhawn.cn',$message);
}
public function getInvoicePdfDownloadUrl()
......
<?php
namespace App\Mailer;
use App\Providers\MailerServiceProvider;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Support\Facades\Mail;
class MailService{
private $type;
public function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
$this->registerProvider($this->getMailAccountConfig());
}
public function setFromType($type)
{
......@@ -22,27 +28,26 @@ class MailService{
$this->registerProvider($this->getMailAccountConfig($this->type));
}
public function getMailAccountConfig()
public function getMailAccountConfig($emailSmtp = 'rhawn')
{
$username = env("MAIL_USERNAME");
$password = env("MAIL_PASSWORD");
$address = env("MAIL_FROM_ADDRESS");
$fromName = env("MAIL_FROM_NAME");
$config = config('mail');
$config['username'] = $username;
$config['password'] = $password;
$config['from']['address'] = $address;
$config['from']['name'] = $fromName;
$config['mailers']['smtp']['host'] = env(strtoupper($emailSmtp)."_MAIL_HOST");
$config['mailers']['smtp']['port'] = env(strtoupper($emailSmtp)."_MAIL_PORT");
$config['mailers']['smtp']['encryption'] = env(strtoupper($emailSmtp)."_MAIL_ENCRYPTION");
$config['mailers']['smtp']['username'] = env(strtoupper($emailSmtp)."_MAIL_USERNAME");
$config['mailers']['smtp']['password'] = env(strtoupper($emailSmtp)."_MAIL_PASSWORD");
$config['from']['address'] = env(strtoupper($emailSmtp)."_MAIL_FROM_ADDRESS");
$config['from']['name'] = env(strtoupper($emailSmtp)."_MAIL_FROM_NAME");
return $config;
}
public function registerProvider($config)
{
config(['mail' => $config]);
app()->register(\Illuminate\Mail\MailServiceProvider::class);
app('config')->set(['mail' => $config]);
$mailerServiceProvider = app(MailerServiceProvider::class);
//$mailerServiceProvider->setMailerPlatform('rhawn');
app()->register($mailerServiceProvider);
}
public function sendMail($title, $toUser, $message)
......@@ -54,4 +59,9 @@ class MailService{
});
}
public function sendMailToHtml($title, $toUser, $message)
{
$this->mailer->html('emails.invoice',['message'=> $message]);
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment