REQ this mod
https://github.com/PHPMailer/PHPMailer/releases
https://github.com/PHPMailer/PHPMailer/releases
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\OAuth;
$GLOBALS["TTMail"] = new TTMail;
class TTMail {
var $type;
var $smtp_host;
var $smtp_port = 465; // Update to Gmail's SMTP port for TLS
var $smtp_ssl = false;
var $smtp_auth = true;
var $smtp_user;
var $smtp_pass;
var $oauth2_client_id; // Add OAuth2 client ID
var $oauth2_client_secret; // Add OAuth2 client secret
var $oauth2_refresh_token; // Add OAuth2 refresh token
function __construct() {
GLOBAL $site_config;
switch (strtolower($site_config["mail_type"])) {
case "phpmailer":
$this->type = "phpmailer";
$this->smtp_host = 'smtp.gmail.com';
$this->smtp_port = 465;
$this->smtp_auth = true;
$this->smtp_user = $site_config["mail_smtp_user"];
$this->smtp_pass = $site_config["mail_smtp_pass"];
// Add OAuth2 settings
$this->oauth2_client_id = $site_config["oauth2_client_id"];
$this->oauth2_client_secret = $site_config["oauth2_client_secret"];
$this->oauth2_refresh_token = $site_config["oauth2_refresh_token"];
// Enable TLS
$this->smtp_ssl = 'tls';
break;
case "pear":
$this->type = "pear";
$this->smtp_ssl = $site_config["mail_smtp_ssl"];
if ($this->smtp_ssl) {
$this->smtp_host = "ssl://" . $site_config["mail_smtp_host"];
} else {
$this->smtp_host = $site_config["mail_smtp_host"];
}
$this->smtp_port = $site_config["mail_smtp_port"];
$this->smtp_auth = $site_config["mail_smtp_auth"];
$this->smtp_user = $site_config["mail_smtp_user"];
$this->smtp_pass = $site_config["mail_smtp_pass"];
if (!@include_once("Mail.php")) {
trigger_error("Config is set to use PEAR Mail but it is not installed (or include_path is wrong).", E_USER_WARNING);
$this->type = "php";
}
break;
case "php":
default:
$this->type = "php";
}
}
function Send($to, $subject, $message, $additional_headers = "", $additional_parameters = "") {
GLOBAL $site_config;
if (preg_match("!^From:(.*)!m", $additional_headers, $matches)) {
$from = trim($matches[1]);
} else {
$from = "$site_config[SITEEMAIL]";
}
$additional_headers = preg_replace("!^From:(.*)!m", "", $additional_headers);
$additional_headers .= "\nFrom: $from\nReturn-Path: $from";
$additional_headers = trim($additional_headers);
$additional_headers = preg_replace("!\n+!", "\n", $additional_headers);
switch ($this->type) {
case "phpmailer":
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = $this->smtp_host;
$mail->Port = $this->smtp_port;
$mail->SMTPAuth = $this->smtp_auth;
$mail->Username = $this->smtp_user;
$mail->Password = $this->smtp_pass;
// Add OAuth2 settings
$mail->OAuth2ClientId = $this->oauth2_client_id;
$mail->OAuth2ClientSecret = $this->oauth2_client_secret;
$mail->OAuth2RefreshToken = $this->oauth2_refresh_token;
$mail->SMTPSecure = $this->smtp_ssl;
$mail->setFrom($from);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;
try {
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
break;
case "pear":
$headers = array("From" => $from, "Return-Path" => $from, "To" => $to, "Subject" => $subject);
$params = array("host" => $this->smtp_host, "port" => $this->smtp_port, "auth" => $this->smtp_auth, "username" => $this->smtp_user, "password" => $this->smtp_pass);
$smtp = Mail::Factory("smtp", $params);
$mail = $smtp->send($to, $headers, $message);
break;
case "php":
default:
@mail($to, $subject, $message, $additional_headers, $additional_parameters);
break;
}
}
}
function sendmail($to, $subject, $message, $additional_headers = "", $additional_parameters = "") {
GLOBAL $TTMail;
$TTMail->Send($to, $subject, $message, $additional_headers, $additional_parameters);
}
?>// BELOW IS SETTINGS FOR OAUTH2 GMAIL. NEED OAUTH2 KEY (see code in mail.php)
// $site_config["mail_type"] = "phpmailer";
// $site_config["mail_smtp_host"] = "smtp.gmail.com"; // SMTP server hostname
// $site_config["mail_smtp_port"] = "465"; // SMTP server port
// $site_config["mail_smtp_ssl"] = true; // true to use SSL (ONLY USED WITH PEAR. Is not used with phpmailer)
// $site_config["mail_smtp_auth"] = true; // MUST BE true to use auth for SMTP (JUST LEAVE SET TO TRUE)
// $site_config["mail_smtp_user"] = "person@gmail.com"; // SMTP username
// $site_config["mail_smtp_pass"] = "Password"; // SMTP password
// $site_config["oauth2_client_id"] = "CLIENT ID HERE"; // OAUTH2 keys from google to use gmail shit
// $site_config["oauth2_client_secret"] = "SECRET KEY HERE";
// $site_config["oauth2_refresh_token"] = ""; //Im not sure how to get this yet.
No users online
Torrents
Members
Online