title: how to send mail with phpmailer class?
body: <p>I created a phpMailer class and call it into my register.php file all fine.
  But dont find a way how to send emails from class.</p>
  
  <p>Here is my class:</p>
  
  <pre><code>class mailSend {
      public function sendMail($email, $message, $subject)
      {
          require_once('PHPMailer/src/Exception.php');
          require_once('PHPMailer/src/PHPMailer.php');
          require_once('PHPMailer/src/SMTP.php');
          $mail = new PHPMailer\PHPMailer\PHPMailer();
          try {
          $mail-&gt;SMTPDebug = 0;
          $mail-&gt;isSMTP();
          $mail-&gt;Host = "smtp.gmail.com";
          $mail-&gt;SMTPAuth = true;
          $mail-&gt;Username = "email@gmail.com";
          $mail-&gt;Password = "password";
          $mail-&gt;Port = 587;
          $mail-&gt;setFrom('admin@example.com', 'Mailer');
          $mail-&gt;addAddress($email);
          $mail-&gt;addReplyTo("user@gmail.com", "Alias");
          $mail-&gt;CharSet = "UTF-8";
          $mail-&gt;isHTML(true);
          $mail-&gt;Subject = $subject;
          $mail-&gt;Body = $message;
          $mail-&gt;send();
              $success['success'] = "Mail sent.";
          } catch (Exception $e) {
              $errors['mail'] = "Failed. Mailer error: {$mail-&gt;ErrorInfo}";
          }
      }
  }
  </code></pre>
  
  <p>This is the usaqe:</p>
  
  <pre><code>require "modules/mailer.php";
  $email_send = new mailSend();
  $email_send-&gt;sendMail($email,$message,$subject);
  </code></pre>
  
  <p>And Here is my problem part, I am trying to send a confirmation link to user on registration and dont know how to do it, I tried several methods but couldnt make it work:</p>
  
  <p>Here is how I am trying to send and having error :</p>
  
  <blockquote>
    <p>Notice: Undefined variable: message in
    D:\Wamp\www\html\modules\register.php on line 115</p>
  </blockquote>
  
  <pre><code>require "modules/mailer.php";
  $email_send = new mailSend();
  $email_send-&gt;sendMail($email,$message,$subject);
  
  $subject = "Please verify email!";
  $message = "Thanks for signing up!&lt;br&gt;
              Please click on the link below:&lt;br&gt;&lt;br&gt;
              &lt;a href=".$url."&gt;".$url."&lt;/a&gt;";
  </code></pre>