Skip to content

5-Minute Quickstart

This quickstart sends an Aegean Voyages (aegeanvoyages.example) charter option confirmation based on site/modules/WireMailPHPMailer/examples/real-world/charter-confirmation-mail.php.

  1. Instantiate a fresh WireMail message:

    <?php declare(strict_types=1);
    namespace ProcessWire;
    $mailer = $wire->mail->new();
  2. Add recipients (to, cc, bcc), subject, text, HTML, and attachment:

    $itineraryPdf = $wire->config->paths->assets . 'brochures/aegean-horizon-gocek.pdf';
    $mailer
    ->to('[email protected]', 'Elena Rossi')
    ->cc('[email protected]', 'Aegean Charter Desk')
    ->from('[email protected]', 'Aegean Voyages')
    ->subject('Charter Option Confirmed: M/Y Aegean Horizon (Gocek)')
    ->body("Your 7-night option hold from Gocek Marina is confirmed.\nPlease review the attached itinerary.")
    ->bodyHTML('<p>Your 7-night option hold from <strong>Gocek Marina</strong> is confirmed.</p>');
    if (is_file($itineraryPdf) && !is_link($itineraryPdf)) {
    $mailer->attachment($itineraryPdf, 'Aegean-Horizon-Itinerary.pdf');
    }
  3. Send and check the delivered recipient count:

    $sentCount = $mailer->send();
    if ($sentCount === 0) {
    $wire->log->save('mail-errors', 'Failed to deliver charter confirmation email.');
    }

Next steps