send()

public function send(array $params): bool

Description

Sends an email via SMTP using the credentials configured in config/trongate_email.php. Supports both HTML and plain text formats. If no plain text version is provided, one is automatically generated from the HTML content.

Parameters

Parameter Type Description Required
params[to_email] string The recipient's email address. Yes
params[to_name] string The recipient's display name. No
params[subject] string The email subject line. Yes
params[body_html] string The HTML content of the email. Yes
params[body_plain] string The plain text version of the email. If omitted, auto-generated from body_html. No

Return Value

TypeDescription
boolReturns true if the email was sent successfully, false if required parameters are missing or the SMTP send failed.

Example Usage

PHP
<?php
$this->trongate_email->send([
    'to_email' => '[email protected]',
    'to_name' => 'John Doe',
    'subject' => 'Welcome to Our Site!',
    'body_html' => '<h1>Welcome!</h1><p>Thanks for joining.</p>'
]);