PHP code example of snipworks / php-smtp
1. Go to this page and download the library: Download snipworks/php-smtp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
snipworks / php-smtp example snippets
use Snipworks\Smtp\Email;
$mail = new Email('smtp.example.com', 25);
$mail->setLogin('[email protected] ', 'password');
$mail->addTo('[email protected] ', 'Example Receiver');
$mail->setFrom('[email protected] ', 'Example Sender');
$mail->setSubject('Example subject');
$mail->setHtmlMessage('<b>Example message</b>...');
if($mail->send()){
echo 'Success!';
} else {
echo 'An error occurred.';
}
use Snipworks\Smtp\Email;
$mail = new Email('smtp.example.com', 587);
$mail->setProtocol(Email::TLS);
$mail->setLogin('[email protected] ', 'password');
$mail->addTo('[email protected] ', 'Example Receiver');
$mail->setFrom('[email protected] ', 'Example Sender');
$mail->setSubject('Example subject');
$mail->setHtmlMessage('<b>Example message</b>...');
if($mail->send()){
echo 'Success!';
} else {
echo 'An error occurred.';
}
// config.php
define('SMTP_PRIMARY_EMAIL', '[email protected] ');
define('SMTP_PRIMARY_PASSWORD', 'my very secret password');
$mail->setLogin(SMTP_PRIMARY_EMAIL, SMTP_PRIMARY_PASSWORD);
// ...
bash
composer