PHP code example of sy / mail

1. Go to this page and download the library: Download sy/mail 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/ */

    

sy / mail example snippets




use Sy\Mail;

$mail = new Mail('[email protected]', 'Hello world', 'This is a test mail!');
$mail->send();



use Sy\Mail;

$mail = new Mail('[email protected]', 'Hello world', 'This is a test mail!');
$mail->setSmtp('smtp.gmail.com', '[email protected]', 'password', 'tls', 587);
$mail->send();



use Sy\Mail;
use Sy\Mail\Template\Html;

$html = new Html('This is a simple html email template!');

$mail = new Mail('[email protected]', 'Simple html template', $html);
$mail->send();



use Sy\Mail;
use Sy\Mail\Template\Html;

$html = new Html();
$html->addImage('https://picsum.photos/600/300', 'Image Alt');
$html->addParagraph('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.');
$html->addButton('Go to website now!', 'https://example.com');
$html->setFooterLink('Unsubscribe', 'https://example.com', "Don't like these emails?");
$html->setPoweredBy('HTML email', 'https://example.com', 'Powered by');

$mail = new Mail('[email protected]', 'Simple html template', $html);
$mail->send();