承接 phicorp/mailbox 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phicorp/mailbox

最新稳定版本:1.0.0

Composer 安装命令:

composer require phicorp/mailbox

包简介

mailBox: a tool for easier work with sending emails for the PHP language

README 文档

README

A tool for easier work with sending emails for the PHP language

Installation

Install Cipher with composer

composer require phicorp/mailbox

Features

  • Easy to use
  • HTML sending support
  • SMTP support
  • And more features

Usage/Examples

  • Send a normal email
use mailBox\mailBox;

// Create an instance of mailBox with SMTP server details.
$mailer = new mailBox('smtp.example.com', 587, 'STARTTLS');

// Set SMTP authentication credentials.
$mailer->auth('your_username', 'your_password');

// Set sender information.
$mailer->setFrom('your_email@example.com', 'Your Name');

// Set recipient email.
$mailer->to('recipient@example.com');

// Set email subject and message.
$mailer->subject('Hello, World!');
$mailer->message('This is a test email sent using mailBox class.');

// Optionally, enable HTML email if needed.
// $mailer->isHTML();

// Send the email.
if ($mailer->send()) {
    echo "Email sent successfully.";
} else {
    echo "Email sending failed.";
}

// Optionally, you can retrieve the logs for debugging purposes.
// $logs = $mailer->getLogs();
  • If you want to use PHP's own built-in functions to send your email, you can use this method
use mailBox\mailBox;

// Create an instance of mailBox with SMTP server details.
$mailer = new mailBox('your_smtp_host', 25, 'tls', 'your_username', 'your_password');

// Set sender information.
$mailer->setFrom('your_email@example.com', 'Your Name');

// Set recipient email.
$mailer->to('recipient@example.com');

// Set email subject and message.
$mailer->subject('Hello, World!');
$mailer->message('<p>This is a test email sent using mailBox class.</p>');

// Enable HTML mode
$mailer->isHTML();

// Send the email.
$result = $mailer->sendRAW();
if ($result) {
    echo "Email sent successfully using default mail() function.";
} else {
    echo "Email could not be sent using default mail() function.";
}
  • Sending by Outlook, with method chaining
mailBox::create('smtp.office365.com', 587)
    ->encryption('STARTTLS')
    ->auth('your_username@outlook.com', 'your_password')
    ->setFrom('your_username@outlook.com', 'your_name')
    ->to('recipient@example.com')
    ->subject("Hello, World!")
    ->message("This is a test email sent using mailBox class.")
    ->send();
  • Sending by Gmail, with method chaining and using helper function
mailBox('smtp.gmail.com', 587)
    ->encryption('STARTTLS')
    ->auth('your_username@gmail.com', 'your_password')
    ->setFrom('your_username@gmail.com', 'your_name')
    ->to('recipient@example.com')
    ->subject("Hello, World!")
    ->message("<p>This is a test email sent using mailBox class.</p>")->isHTML()
    ->send();

Authors

License

MIT

统计信息

  • 总下载量: 76
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-07