承接 mathsgod/phpmailer-gmail 相关项目开发

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

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

mathsgod/phpmailer-gmail

最新稳定版本:1.0.0

Composer 安装命令:

composer require mathsgod/phpmailer-gmail

包简介

README 文档

README

This project provides a GmailMailer class for sending emails via Gmail SMTP using PHPMailer and OAuth2 authentication.

Features

  • Send emails through Gmail SMTP securely
  • Uses OAuth2 (no need for less secure app access)
  • Simple integration with your PHP projects

Installation

  1. Clone or download this repository.

  2. Install dependencies using Composer:

    composer install

Usage

  1. Obtain your Gmail address, Google OAuth2 client ID, client secret, and refresh token.

  2. Use the GmailMailer class in your PHP script:

    require 'vendor/autoload.php';
    use PHPMailer\GmailMailer;
    
    $gmail = 'your-email@gmail.com';
    $clientId = 'YOUR_GOOGLE_CLIENT_ID';
    $clientSecret = 'YOUR_GOOGLE_CLIENT_SECRET';
    $refreshToken = 'YOUR_REFRESH_TOKEN';
    
    $mailer = new GmailMailer(true, $gmail, $clientId, $clientSecret, $refreshToken);
    $mailer->addAddress('recipient@example.com');
    $mailer->Subject = 'Test Email';
    $mailer->Body = 'This is a test email sent via Gmail SMTP with OAuth2.';
    
    if ($mailer->send()) {
        echo "Message sent!";
    } else {
        echo "Mailer Error: " . $mailer->ErrorInfo;
    }

How to Get OAuth2 Credentials

For detailed instructions on obtaining OAuth2 credentials and generating a refresh token, please refer to the thephpleague/oauth2-google GitHub repository.

License

MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-27