rodrigoq/phpmailersendgrid
最新稳定版本:1.0.6
Composer 安装命令:
composer require rodrigoq/phpmailersendgrid
包简介
PHPMailer extension to send emails via Sendgrid (or save to file).
README 文档
README
PHPMailer extension to send emails via Sendgrid (or save to file).
Installation & loading
PHPMailerSendGrid is available on Packagist (using semantic versioning), and installation via Composer is the recommended way to install PHPMailer. Just add this line to your composer.json file:
"rodrigoq/phpmailersendgrid": "^1.0"
or run
composer require rodrigoq/phpmailersendgrid
Dependencies
This project depends on
- PHPMailer
- sendgrid-php
- The Sendgrid service
A Simple Example
<?php // Import PHPMailerSendGrid classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailerSendGrid; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require '../vendor/autoload.php'; $mail = new PHPMailerSendGrid(true); // Passing `true` enables exceptions try { //SendGrid settings $mail->isSendGrid(); // Set mailer to use SendGrid // Set the SendGrid API Key, to do it securely check: // https://github.com/sendgrid/sendgrid-php/blob/master/README.md $mail->SendGridApiKey = ''; // SendGrid API Key. //Uncomment to save email to file // $mail->isFile(); // $mail->EmailFilePath = '/var/log/email/'; //Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient $mail->addAddress('ellen@example.com'); // Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); //Attachments $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>.'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients.'; $mail->send(); echo 'Message has been sent.'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; }
License
This software is distributed under the LGPL 3.0 license. Please read LICENSE for information on the software availability and distribution.
统计信息
- 总下载量: 2.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2018-05-25