35 lines
1.2 KiB
PHP
35 lines
1.2 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 = env('EMAIL_ADDRESS_RECEPIENT', null);
|
||
|
$this->email_prefix_subject = env('EMAIL_PREFIX_SUBJECT', null);
|
||
|
$this->nextcloud_upload_folder_web_link = env('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;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|