/** * Fall back to traditional autoload for old PHP versions * @param string $classname The name of the class to load */ function __autoload($classname) { PHPMailerAutoload($classname); }
public function __construct() { //Übername Einstellungen global $gL10n, $gPreferences, $gDebug; //Wir zeigen richtige Fehlermeldungen an $this->exceptions = TRUE; $this->emCopyToSender = false; $this->emListRecipients = false; $this->emSendAsHTML = false; $this->emText = ''; // content of text part $this->emHtmlText = ''; // content of html part //Hier werden noch mal alle Empfaenger der Mail reingeschrieben, //fuer den Fall das eine Kopie der Mail angefordert wird... $this->emAddresses = ''; //Versandmethode festlegen if ($gPreferences['mail_send_method'] == 'SMTP') { PHPMailerAutoload('smtp'); $this->IsSMTP(); $this->Host = $gPreferences['mail_smtp_host']; $this->SMTPAuth = $gPreferences['mail_smtp_auth']; $this->Port = $gPreferences['mail_smtp_port']; $this->SMTPSecure = $gPreferences['mail_smtp_secure']; $this->AuthType = $gPreferences['mail_smtp_authentication_type']; $this->Username = $gPreferences['mail_smtp_user']; $this->Password = $gPreferences['mail_smtp_password']; $this->Debugoutput = 'error_log'; if ($gDebug) { $this->SMTPDebug = 2; } } else { $this->IsMail(); } // set language for error reporting $this->SetLanguage($gL10n->getLanguageIsoCode()); $this->CharSet = $gPreferences['mail_character_encoding']; }
/** * Отправка почты через PHPMailer * @param String $to - кому * @param String $subject - тема письма * @param String $message - текст сообщения * @param String $altmessage - альтернативное сообщение * @param Boolean $smtp - отправка почты через SMTP * @param Boolean $cc - отправлять копию письма * @return Boolean */ public function send_mail($to, $subject = '[WebMCR]', $message = '', $altmassage = '', $smtp = false, $cc = false) { require MCR_TOOL_PATH . 'smtp/PHPMailerAutoload.php'; PHPMailerAutoload('smtp'); include_once MCR_TOOL_PATH . 'smtp/class.phpmailer.php'; $mail = new PHPMailer(); //$mail->SMTPDebug = 3; if ($this->config->mail['smtp']) { $mail->isSMTP(); $mail->Host = $this->config->mail['smtp_host']; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $this->config->mail['smtp_user']; // SMTP username $mail->Password = $this->config->mail['smtp_pass']; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to } $mail->CharSet = 'UTF-8'; $mail->setLanguage('ru', MCR_TOOL_PATH . 'smpt/language/'); $mail->From = $this->config->mail['smtp'] ? $this->config->mail['smtp_user'] : $this->config->mail['from']; $mail->FromName = $this->config->mail['from_name']; if (is_array($to)) { foreach ($to as $key => $value) { $mail->addAddress($value); } } else { $mail->addAddress($to); } $mail->addReplyTo($this->config->mail['reply'], $this->config->mail['reply_name']); if ($this->config->mail['cc']) { $mail->addCC($this->config->mail['from']); } //$mail->addBCC($this->config->mail['bcc']); $mail->isHTML(true); // Set email format to HTML $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $altmassage; return $mail->send(); }
// error debug // error_reporting(E_ALL); // ini_set('display_errors', 1); header("Content-type: application/json"); require_once 'Exceptions/ErrorLoginException.php'; require_once 'Module.php'; require_once 'PDOFactory.php'; require_once 'phpmailer/PHPMailerAutoload.php'; require_once 'JSONAPI.php'; require_once 'MagicObject.php'; JSONAPI::loadExceptions(); JSONAPI::loadMagicObjects(); JSONAPI::loadModules(); // PHPMailer Configuration PHPMailerAutoload("phpmailer"); PHPMailerAutoload("smtp"); $mailFact = new PHPMailerSMTPMagic(); $mail = PHPMailerSMTPMagic::getPhpmailobj(); $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Host = ""; $mail->port = 0; $mail->Username = ""; $mail->Password = ""; PHPMailerSMTPMagic::setPhpmailobj($mail); // DB Configuration PDOFactory::setDbCharset("utf-8"); PDOFactory::setDbHost("localhost"); PDOFactory::setDbName("DBNAME"); PDOFactory::setDbUser("root"); PDOFactory::setDbPassword("");