PHP code example of trk / processwire-php-mailer

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

    

trk / processwire-php-mailer example snippets


$mail = wire('modules')->get('WireMailPHPMailer');

$mail->from('[email protected]')
     ->fromName('Sender Name')
     ->to('[email protected]')
     ->subject('Your Subject Here')
     ->body('This is the plain-text message body.')
     ->bodyHTML('<h1>This is the HTML message body</h1>')
     ->send();

/** @var WireMailPHPMailer $wireMail */
$wireMail = wire('modules')->get('WireMailPHPMailer');

// Retrieve the initialized PHPMailer instance 
// (passing `false` skips loading the module configurations if needed)
$mail = $wireMail->getInstance();

$mail->addAddress('[email protected]', 'Recipient Name');
$mail->isHTML(true);
$mail->Subject = 'Advanced PHPMailer Usage';
$mail->Body    = '<h1>Hello World</h1><p>ProcessWire + PHPMailer</p>';
$mail->AltBody = 'Hello World - ProcessWire + PHPMailer';

if ($mail->send()) {
    echo "Message has been sent.";
} else {
    echo "Message could not be sent. Mailer Error: " . $mail->ErrorInfo;
}