PHP code example of mouf / utils.mailer.mail-interface

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

    

mouf / utils.mailer.mail-interface example snippets


interface MailServiceInterface {
	
	/**
	 * Sends the mail passed in parameter.
	 *
	 * @param MailInterface $mail The mail to send.
	 */
	function send(MailInterface $mail);
}

$mailService = Mouf::getSmtpMailService();

$mail = new Mail();
$mail->setBodyText("This is my mail!");
$mail->setBodyHtml("This is my &lt;b&gt;mail&lt;/b&gt;!");
$mail->setFrom(new MailAddress("[email protected]", "Server"));
$mail->addToRecipient(new MailAddress("[email protected]", "David"));
$mail->setTitle("My mail");

$mailService->send($mail);

$mail = new Mail();
$mail->setBodyHtml("This is my &lt;b&gt;mail&lt;/b&gt;!");
// No need to call $mail->setBodyText()

$mail = new Mail();
$mail->setBodyHtml("This is my &lt;b&gt;mail&lt;/b&gt;!");
// Disable plaing text generation from HTML. The mail will NOT contain the plain text part.
$mail->autoCreateBodyText(false);