PHP code example of shuchkin / simplemail
1. Go to this page and download the library: Download shuchkin/simplemail 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/ */
shuchkin / simplemail example snippets
$mail = new Shuchkin\SimpleMail();
$mail->setFrom('[email protected] ')
->setTo('[email protected] ')
->setSubject('Test SimpleMail')
->setText('Hi, Sergey!')
->send();
// setup mail
$mail = new Shuchkin\SimpleMail();
$mail->setFrom('[email protected] ', 'Example');
// fabric method to( $toEmail )
$mail->to('[email protected] ')
->setSubject('Account activation')
->setHTML('<html><body><p><b>Your account has activated!</b></p></body></html>', true)
->send();
// fabric method compose( $toEmail, $subject, $text )
$mail->compose('[email protected] ', 'New Account', 'https://example.com/useradmin/123')->send();
$mail = new Shuchkin\SimpleMail('smtp', [
'host' => 'ssl://smtp.yandex.ru',
'port' => 465,
'username' => '[email protected] ',
'password' => 'test'
]);
$mail->setFrom('[email protected] )
->setTo('[email protected] ')
->setSubject('Test SMTP')
->setText('Yandex SMTP secured server')
->send();
$mail = new Shuchkin\SimpleMail();
$mail->setFrom('[email protected] ')
->setTo('[email protected] ')
->setSubject('Test attachments')
->setHTML('<html><body><p>See attached price list.</p><p><img src="logo.jpg" /> Logo</p></body></html>')
->attach( __DIR__.'/doc/PriceList.pdf')
->attach( __DIR__.'/images/logo400x300.jpg', 'logo.jpg')
->setReply('[email protected] ')
->send();
$mail = new Shuchkin\SimpleMail();
$mail->setFrom('[email protected] ')
->setTo('[email protected] ')
->setSubject('WARNING!')
->setText('SERVER DOWN!')
->setPriority('urgent')
->setCustomHeaders(['Cc' => '[email protected] '])
->send();
$mail = new Shuchkin\SimpleMail( function( $mail, $encoded ) {
print_r( $encoded );
});
$mail->setFrom('[email protected] ')
->setTo('[email protected] ')
->setSubject('WARNING!')
->setText('SERVER DOWN!')
->send();
/*
Array
(
[from] => [email protected]
[to] => [email protected]
[subject] => =?UTF-8?B?V0FSTklORyE=?=
[message] => SERVER DOWN!
[headers] => To: [email protected]
Subject: =?UTF-8?B?V0FSTklORyE=?=
X-Mailer: PHP/7.2.14
MIME-Version: 1.0
From: [email protected]
Reply-To: [email protected]
Date: Mon, 18 Feb 2019 13:17:28 +0000
Content-Type: text/plain; charset="UTF-8"
)
*/