gartmedia/php-email-library

该软件包最新版本(v1.1)没有可用的许可证信息。

为 GARTMedia 提供的 PHP 邮件/表单处理

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

This package is auto-updated.

Last update: 2024-09-17 23:17:30 UTC


README

PHPmailer 包装器,方便使用

使用方法

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;
}