ouranoshong/php-mailer

通过HTTP代理的SMTP邮件发送器

v0.2 2020-07-02 07:52 UTC

This package is auto-updated.

Last update: 2024-09-11 16:21:07 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Coverage Status

使用SMTP发送电子邮件(支持HTTP代理)

安装

composer require ouranoshong/php-mailer

用法

简单用法演示

<?php

$transport = new \Ouranoshong\Mailer\SMTPTransport(
    [
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'encryption' => 'ssl',
        'username' => 'your username',
        'password' => 'your password'
    ]
);

$mailer = new \Ouranoshong\Mailer\Mailer($transport);
$mailer->setFrom('from@example.com')
    ->setTo('to@example.com')
    ->setSubject('subject')
    ->setText('email from php mailer')
    ->send();

HTTP代理用法演示

$transport = new \Ouranoshong\Mailer\SMTPTransport(
    [
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'encryption' => 'ssl',
        'username' => 'your username',
        'password' => 'your password',
        
        'httpProxy' => 'http://proxy.com:8080' //use http proxy
    ]
);

$mailer = new \Ouranoshong\Mailer\Mailer($transport);
$mailer->setFrom('from@example.com')
    ->setTo('to@example.com')
    ->setSubject('subject')
    ->setText('email from php mailer')
    ->send();