35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\ThirdPartyServices;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Mail\sendExportNotice;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use RuntimeException;
|
|
|
|
class EmailService extends Controller
|
|
{
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
$this->email_address_recepient = config('mail.email_address_recepient', null);
|
|
$this->email_prefix_subject = config('mail.email_prefix_subject', null);
|
|
$this->nextcloud_upload_folder_web_link = config('mail.nextcloud_upload_folder_web_link', false);
|
|
}
|
|
function send_export_via_email(string $from_date, string $to_date, string $file_name){
|
|
try{
|
|
$email_subject = $this->email_prefix_subject . ' '. $from_date.' - '.$to_date;
|
|
Mail::to($this->email_address_recepient)->send(new sendExportNotice(['export_date' => $email_subject, 'file_name' => $file_name, 'upload_folder_web_link' => $this->nextcloud_upload_folder_web_link], $email_subject));
|
|
return true;
|
|
}catch (\Exception $e) {
|
|
Log::error('send_export_via_email Email error - ' . $e->getMessage());
|
|
//throw new RuntimeException("E-EMAIL");
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|