gartmedia/php-email-library

There is no license information available for the latest version (v1.1) of this package.

PHP email/form handling for GARTMedia

v1.1 2024-06-17 22:47 UTC

This package is auto-updated.

Last update: 2025-06-18 00:59:48 UTC


README

Wrapper for PHPmailer for ease of use

Usage

use Email\Email;
use Email\EmailAddress as Address;

$data = [
    "from" => Address::newAddress($email, $name),
    "to" => [
        Address::newAddress("info@example.com", "Max Mustermann")
    ],
    // add custom fields to message body
    "body" => [
        "subject" => $subject,
        "customField" => $customField
    ],
    // attach files to mail
    "files" => [
      ["tmp_name" => "temp", "name" => "test.txt"],
      ["tmp_name" => "temp2", "name" => "test2.txt"]
    ]
];

$settings = [
    // enables recaptcha authentication
    "recaptcha" => [
        "secret" => "your recaptcha secret",
        "response" => $recaptchaResponse,
        "scoreThreshold" => 0.9 // recaptcha v3 score threshold (default = 0.5)
    ],
    "html" => true // enable html mail
];

$mail = new Email($data, $settings);

try {
    $mail->send();
} catch (Exception $e) {
    echo $e;
}