PHP code example of eoghanobrien / php-simple-mail

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

    

eoghanobrien / php-simple-mail example snippets


$mailer = new SimpleMail();

$mailer = SimpleMail::make();

SimpleMail::make()
->setTo($email, $name)
->setFrom($fromEmail, $fromName)
->setSubject($subject)
->setMessage($message)
->send();

SimpleMail::make()
 ->setTo($email1, $name1)
 ->setTo($email2, $name2);

SimpleMail::make()
  ->setFrom('[email protected]', 'John Smith');

SimpleMail::make()
  ->setCc(['John Smith', '[email protected]');

SimpleMail::make()
  ->setBcc(['John Smith', '[email protected]');

SimpleMail::make()
    ->setSubject("Important information about your account");

SimpleMail::make()
    ->setMessage("My important message!");

SimpleMail::make()
    ->setMessage("<strong>My important message!</strong>")
    ->setHtml();

SimpleMail::make()
    ->setMessage("<strong>My important message!</strong>")
    ->send();

$send = SimpleMail::make()
    ->setTo($email, $name)
    ->setFrom($fromEmail, $fromName)
    ->setSubject($subject)
    ->setMessage($message)
    ->setReplyTo($replyEmail, $replyName)
    ->setCc(['Bill Gates' => '[email protected]'])
    ->setBcc(['Steve Jobs' => '[email protected]'])
    ->setHtml()
    ->setWrap(100)
    ->send();
    
echo ($send) ? 'Email sent successfully' : 'Could not send email';

$send = SimpleMail::make()
    ->setTo($email, $name)
    ->setFrom($fromEmail, $fromName)
    ->setSubject($subject)
    ->setMessage($message)
    ->setReplyTo($replyEmail, $replyName)
    ->setCc(['Bill Gates' => '[email protected]'])
    ->setBcc(['Steve Jobs' => '[email protected]'])
    ->setHtml()
    ->setWrap(100)
    ->addAttachment('example/pbXBsZSwgY2hh.jpg', 'lolcat_finally_arrived.jpg')
    ->addAttachment('example/lolcat_what.jpg')
    ->send();
    
echo ($send) ? 'Email sent successfully' : 'Could not send email';

$ composer