PHP code example of jalle19 / sanemail

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

    

jalle19 / sanemail example snippets


$mail = new SaneMail\Mail();
$mail->addFrom('[email protected]', 'Disgruntled programmer');
$mail->addTo('[email protected]');
$mail->addCc('[email protected]');
$mail->addBcc('[email protected]');
$mail->addReplyTo('[email protected]');
$mail->setSubject('This is a working e-mail');

$html = '<html><head><title></title></head><body><h1>This is HTML</h1><p>This is a paragraph</p></body></html>';
$text = "This is plain-text\n\nThis is a paragraph";

$mail->setBodyText($text);
$mail->setBodyHtml($html);

try {
	$mail->send();
}
catch(SaneMail\Exception $e) {
	// Zend\Mail\Exception\RuntimeException available from $e->getPrevious()
}