send email with smtp (support http proxy)
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();
$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();