| <?php | 
 | require_once "Mail.php"; | 
 | include('Mail/mime.php'); | 
 | include 'config.php'; | 
 |  | 
 | function send_mail(string $email, object $smtp, object $message) { | 
 |     include 'config.php'; | 
 |  | 
 |     $crlf = "\r\n"; | 
 |  | 
 |     $headers = array( | 
 |         'From' => $smtp->from, | 
 |         'To' => $email, | 
 |         'Subject' => $message->subject | 
 |     ); | 
 |  | 
 |     if (isset($CC_MAIL)) { | 
 |         $headers['Cc'] = $CC_MAIL; | 
 |         $email .= ', ' . $CC_MAIL; | 
 |     } | 
 |  | 
 |     if (isset($BCC_MAIL)) { | 
 |         $email .= ', ' . $BCC_MAIL; | 
 |     } | 
 |  | 
 |     $smtp = Mail::factory('smtp', array( | 
 |             'host' => $smtp->host, | 
 |             'port' => $smtp->port, | 
 |             'auth' => true, | 
 |             'username' => $smtp->username, //your gmail account | 
 |             'password' => $smtp->password // your password | 
 |         )); | 
 |  | 
 |     // Creating the Mime message | 
 |     $mime = new Mail_mime(array( | 
 |         "text_charset" => "utf-8", | 
 |         "html_charset" => "utf-8", | 
 |         "eol" => $crlf | 
 |     )); | 
 |  | 
 |     // Setting the body of the email | 
 |     $mime->setTXTBody($message->text); | 
 |     $mime->setHTMLBody($message->html); | 
 |  | 
 |     $body = $mime->get(); | 
 |     $headers = $mime->headers($headers); | 
 |  | 
 |     // Send the mail | 
 |     $mail = $smtp->send($email, $headers, $body); | 
 |  | 
 |     //check mail sent or not | 
 |     if (PEAR::isError($mail)) { | 
 |         return false; | 
 |     } else { | 
 |         return true; | 
 |     } | 
 | } | 
 |  | 
 | /* send_mail("mattf@tilde.club", $SMTP, (object) [ */ | 
 | /*     "subject" => "Please confirm your email", */  | 
 | /*     "text" => "Plain tet", */ | 
 | /*     "html" => "<html><body><p>HTML message</p><h2>This is not mere text</h2></body></html>" */ | 
 | /* ]) */ | 
 | ?> |