HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/orbidirectory.com/app/Services/MailchimpService.php
<?php

namespace App\Services;
use MailchimpTransactional\ApiClient;

class MailchimpService
{
    protected $client;
    /**
     * Create a new class instance.
     */
    public function __construct()
    {
        $this->client = new ApiClient;
        $this->client->setApiKey(env('MAILCHIMP_API_KEY'));
    }

   public function sendEmail($to, $subject, $body)
    {
        $message = [
            'from_email' => '[email protected]',
            'subject' => $subject,
            'html' => $body,
            'to' => [
                [
                    'email' => $to,
                    'type' => 'to'
                ]
            ]
        ];

        try {
            $response = $this->client->messages->send([
                'message' => $message
            ]);

            return $response;
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
}