A helper function for sending an email

The message.php file

See \murach\book_apps\ch22_register_email\model

How to use the helper function to send an email

How to use the send_email() function

      <?php
      require_once 'message.php'; 
      $from_address = 'johndoe@example.com'; 
      $from_name = 'John Doe'; 
      $to_address = 'janedoe@example.com'; 
      $to_name = 'Jane Doe'; 
      $subject = 'How to use PHPMailer'; 
      $body = 'The Murach PHP and MySQL book has a chapter on how to use PHPMailer 
      <a href="https://github.com/PHPMailer/PHPMailer">PHPMailer</a> to send email.'; $is_body_html = true; 
      try {
        send_email($to_address, $to_name, $from_address, $from_name, $subject, $body, $is_body_html);
        echo("Mail was sent successfully.&;t/br />>");
      } catch (Exception $e) { 
        echo("Error " . $e->getMessage() . "<br />>");
      }
      ?> 

Description

Back