thedavidinyang/phpsimplemail

一个功能齐全的简单PHP流畅接口,用于通过SMTP发送HTML或纯文本电子邮件

1.3 2024-05-29 14:37 UTC

This package is auto-updated.

Last update: 2024-09-29 15:15:48 UTC


README

一个功能齐全的简单PHP流畅接口,用于通过SMTP发送HTML或纯文本电子邮件

<?php
$e = new Mailer;

$setup = ['host' => '', 'username'=>'', 'password'=>'', 'authentication'=>'', 'port'=>''  ]

$e->init($setup)
->subject('Welcome')
->to(['name' => 'David Inyang', 'email'=>'samplemail@gmail.com'])
->from(['name' => 'David Inyang', 'email'=>'samplemail@gmail.com'])
->body('Hi, welcome to the team')
->sendmail();

这是一个简单的邮件接口,使发送SMTP电子邮件变得极其简单。

您可以发送纯文本或HTML电子邮件,并轻松从流畅的接口中添加附件。

它提供了构建几乎所有类型电子邮件所需的所有基本元素。

配置

  • host = smtp主机URL
  • username = smtp用户名
  • password = smtp密码
  • authentication = SSL或TLS
  • port = smtp端口号

简单安装

使用Composer安装

要使用Composer安装,只需要求此包的最新版本。

composer require thedavidinyang/phpsimplemail

确保加载Composer的autoload文件。

// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require 'vendor/autoload.php';

下载并安装

下载一个打包的存档并将其解压到包将驻留的目录中

快速入门

只需将您的邮件配置传递给PHPSimplemail

// reference the SimpleMail namespace
use thedavidinyang\SimpleMail\Mailer;

// Setup SMTP Configurations
$setup = ['host' => '', 'username'=>'', 'password'=>'', 'authentication'=>'', 'port'=>''  ]

// initialize and use the SimpleMail class
$e = new Mailer;

$e->init($setup)

// Set mail parameters

// Subject
->subject('Welcome')

// Recipient
->to(['name' => 'David Inyang', 'email'=>'samplemail@gmail.com'])

// Sender
->from(['name' => 'David Inyang', 'email'=>'samplemail@gmail.com'])

// Content
->body('Hi, welcome to the team')

// Send mail
->sendmail();