Titan-2 Mini FW kullanılıyor.
Alakası bulunan dosyaları aşağıya bırakıyorum.
/home/ks/subdomain.domain.com/App/Controllers/Admin/Admin.php
<?php
namespace App\Controllers\Admin;
use System\Kernel\Controller;
use View;
use Model;
use Request;
use Session;
use Upload;
use Cookie;
use System\Libs\Mail\Mail;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
require 'vendor/autoload.php';
class Admin extends Controller
{
public function sendEmail()
{
$userMailList = Model::run('Users')->getUserMails();
$data = array(
"page" => "page.sendEmail",
"userMails"=>$userMailList,
"foundpage"=>"sendEmail"
);
View::render('admin.index', $data);
}
public function sendEmailPOST()
{
$userMailList = Model::run('Users')->getUserMails();
try {
/*foreach($userMailList as $m)
$mail->addAddress($m["Eposta"]);*/
$mail = new PHPMailer();
foreach(['testmail1@gmail.com',/* 'testmail2@hotmail.com',*/ 'testmail3@icloud.com', 'testmail4@gmail.com', 'testmail5@gmail.com', 'testmail6@gmail.com'] as $tm)
$mail->addAddress($tm);
// $mail->Host = 'smtp-mail.outlook.com';
$mail->Host = 'smtp.office365.com';
$mail->Username = 'myMail@hotmail.com';
$mail->Password = 'myPassWord';
$mail->Port = 587;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->setFrom('myMail@hotmail.com', 'My Name X');
$mail->Subject = Request::post('baslik');
$mail->Body = Request::post('content');
$mail->send();
} catch (Exception $e) {
echo "ERROR: ". $e;
echo "ERROR: ". $mail->ErrorInfo;
}
echo "GÖNDERİLDİ !";
}/home/ks/subdomain.domain.com/System/Libs/Mail/Mail.php<?php
namespace System\Libs\Mail;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class Mail extends PHPMailer
{
// Mail config items
protected $config = [];
public function __construct()
{
parent::__construct();
// Getting mail config items
$this->config = config('app.email');
// Setting SMTP Protocol
$this->isSMTP();
// Default SMTP Auth
$this->SMTPAuth = true;
// Default HTML Format
$this->isHTML(true);
// SMTP Server
$this->Host = $this->config['server'];
// Username
$this->Username = $this->config['username'];
// User Password
$this->Password = $this->config['userpass'];
// Default Port
$this->Port = $this->config['port'];
// Default Charset
$this->CharSet = $this->config['charset'];
}
/**
* Mail settings
*
* @param array $config
* @return void
*/
public function init($config)
{
if(array_key_exists('charset', $config))
$this->CharSet = $config['charset'];
if(array_key_exists('server', $config))
$this->Host = $config['server'];
if(array_key_exists('port', $config))
$this->Port = $config['port'];
if(array_key_exists('username', $config))
$this->Username = $config['username'];
if(array_key_exists('userpass', $config))
$this->Password = $config['userpass'];
if(array_key_exists('isHtml', $config))
$this->isHTML($config['isHtml']);
}
/**
* Set SMTP host
*
* @param string $host
* @return void
*/
public function setHost($host)
{
$this->Host = $host;
}
/**
* Get SMTP host
*
* @return string
*/
public function getHost()
{
return $this->Host;
}
/**
* Set SMTP port
*
* @param integer $port
* @return void
*/
public function setPort($port)
{
$this->Port = $port;
}
/**
* Get SMTP port
*
* @return integer
*/
public function getPort()
{
return $this->Port;
}
/**
* Set SMTP username
*
* @param string $username
* @return void
*/
public function setUsername($username)
{
$this->Username = $username;
}
/**
* Get SMTP username
*
* @return string
*/
public function getUsername()
{
return $this->Username;
}
/**
* Set SMTP password
*
* @param string $password
* @return void
*/
public function setPassword($password)
{
$this->Password = $password;
}
/**
* Get SMTP password
*
* @return string
*/
public function getPassword()
{
return $this->Password;
}
/**
* Set SMTP charset
*
* @param string $charset
* @return void
*/
public function setCharset($charset)
{
$this->Charset = $charset;
}
/**
* Get SMTP charset
*
* @return string
*/
public function getCharset()
{
return $this->Charset;
}
/**
* Set SMTP is Html
*
* @param boolean $html
* @return void
*/
public function setHtml($html)
{
if (is_bool($html))
$this->isHTML($html);
}
/**
* Get SMTP is Html
*
* @return boolean
*/
public function getHtml()
{
return $this->isHTML();
}
/**
* Set mail subject
*
* @param string $subject
* @return void
*/
public function subject($subject)
{
$this->Subject = $subject;
}
/**
* Set body of mail
*
* @param string $body
* @return void
*/
public function body($body)
{
$this->Body = $body;
}
/**
* Set alt body of mail
*
* @param string $altBody
* @return void
*/
public function altBody($altBody)
{
$this->AltBody = $altBody;
}
/**
* Get SMTP errors
*
* @return string
*/
public function getError()
{
return $this->ErrorInfo;
}
/**
* Call PhpMailer's methods
*
* @param string $method
* @param string $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
return call_user_func_array([new PHPMailer, $method], $args);
}
function __destruct()
{
parent::__destruct();
}
}/home/ks/subdomain.domain.com/vendor/phpmailer/phpmailer/src/PHPMailer.php<?php
namespace PHPMailer\PHPMailer;
class PHPMailer
{
.../home/ks/subdomain.domain.com/vendor/composer/autoload_psr4.php<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Windwalker\\Edge\\' => array($vendorDir . '/windwalker/edge'),
'Whoops\\' => array($vendorDir . '/filp/whoops/src/Whoops'),
'System\\' => array($baseDir . '/System'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
'App\\' => array($baseDir . '/App'),
);/home/ks/subdomain.domain.com/composer.json{
"name": "tkaratug/titan2",
"type": "project",
"description": "Titan 2 Mini Framework",
"keywords": ["titan 2","mvc","mini","framework"],
"homepage": "https://github.com/tkaratug/titan2",
"license": "MIT",
"authors": [
{
"name": "Turan Karatuğ",
"email": "tkaratug@hotmail.com.tr",
"homepage": "http://turankaratug.com",
"role": "Developer"
}
],
"require": {
"php": ">=7.0.0",
"filp/whoops": "^2.1",
"windwalker/edge": "3.4.7",
"phpmailer/phpmailer": "~6.0"
},
"autoload": {
"psr-4": {
"App\\": "App",
"System\\": "System",
"PHPMailer\\PHPMailer\\": "src/"
}
},
"config": {
"preferred-install": "dist"
}
}