Skip to content

Commit 3740d0f

Browse files
committed
Phpmailer ve email şablonu ayarlandı
1 parent b56883a commit 3740d0f

75 files changed

Lines changed: 8999 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ DB_HOST= localhost
88
DB_NAME= crm_milik
99
DB_USERNAME=root
1010
DB_PASSWORD=
11+
12+
## Email
13+
14+
EMAIL_USERNAME=4c2803aa5b391b
15+
EMAIL_PASSWORD=be4f6c33ce3ac7
16+
SMTP_PORT=465
17+
SMTP_HOST=smtp.mailtrap.io
18+
ADMIN_EMAIL=ytoluyag@gmail.com

app/classes/Mail.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
4+
namespace App\Classes;
5+
6+
use PHPMailer\PHPMailer\PHPMailer;
7+
8+
class Mail
9+
{
10+
protected $mail;
11+
12+
public function __construct()
13+
{
14+
$this->mail = new PHPMailer;
15+
$this->setUp();
16+
}
17+
18+
public function setUp()
19+
{
20+
$this->mail->isSMTP();
21+
$this->mail->Mailer = 'smtp';
22+
$this->mail->SMTPAuth = true;
23+
$this->mail->SMTPSecure = 'tls';
24+
25+
$this->mail->Host = getenv('SMTP_HOST');
26+
$this->mail->Port = getenv('SMTP_PORT');
27+
28+
$environment = getenv('APP_ENV');
29+
30+
if ($environment === 'local') {
31+
$this->mail->SMTPDebug = 2;
32+
}
33+
34+
$this->mail->Username = getenv('EMAIL_USERNAME');
35+
$this->mail->Password = getenv('EMAIL_PASSWORD');
36+
$this->mail->isHTML(true);
37+
$this->mail->SingleTo = true;
38+
39+
$this->mail->From = getenv('ADMIN_EMAIL');
40+
$this->mail->FromName = getenv('');
41+
}
42+
43+
public function send($data)
44+
{
45+
$this->mail->addAddress($data['to'],$data['name']);
46+
$this->mail->Subject = $data['subject'];
47+
$this->mail->Body = make($data['view'],array('data'=>$data['body']));
48+
return $this->mail->send();
49+
}
50+
}

app/controllers/IndexController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,27 @@
33

44
namespace App\Controllers;
55

6+
use App\Classes\Mail;
7+
68

79
class IndexController extends BaseController
810
{
911
public function show()
1012
{
1113
echo 'Burası Ana Baba Günü';
14+
$mail = new Mail();
15+
$data = [
16+
'to' => 'test@example.com',
17+
'subject' => 'Hoşgeldiniz Biladerim',
18+
'view'=>'welcome',
19+
'body'=> 'Test Ediyoruz Email Şablonunu'
20+
21+
];
22+
23+
if ($mail->send($data)) {
24+
echo 'email Başarıyla Gönderildi';
25+
} else {
26+
echo 'email Gönderilemedi';
27+
}
1228
}
1329
}

app/functions/helper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,16 @@ function view($path, array $data = [])
88
$cache = __DIR__ . '/../../bootstrap/cache';
99
$blade = new Blade($view, $cache);
1010
echo $blade->view()->make($path, $data)->render();
11+
}
12+
13+
function make($filename, $data)
14+
{
15+
16+
extract($data);
17+
ob_start();
18+
include(__DIR__ . '/../../resources/views/emails/'.$filename.'.php');
19+
$content = ob_get_contents();
20+
ob_end_clean();
21+
22+
return $content;
1123
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"vlucas/phpdotenv": "^3.3",
44
"altorouter/altorouter": "^1.2",
55
"philo/laravel-blade": "^3.1",
6-
"illuminate/database": "^5.8"
6+
"illuminate/database": "^5.8",
7+
"phpmailer/phpmailer": "^6.0"
78
},
89
"autoload": {
910
"psr-4": {

composer.lock

Lines changed: 67 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
$bul = Capsule::table('musteriler')->get();
1212

13-
var_dump($bul);
13+
//var_dump($bul);

resources/views/emails/welcome.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="tr">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<div style="width: 500px; padding: 15px; margin: 0 auto; background-color: darkred">
9+
<img width="150px" height="75px" src="https://yt3.ggpht.com/a-/AAuE7mAzi4VaiH3-qZFpvB93AcQQVuq7Rq90ohCb9Q=s900-mo-c-c0xffffffff-rj-k-no" alt="BabaFinger">
10+
<?php echo $data; ?>
11+
</div>
12+
13+
</body>
14+
</html>

vendor/composer/autoload_classmap.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
return array(
99
'AltoRouter' => $vendorDir . '/altorouter/altorouter/AltoRouter.php',
10+
'App\\Classes\\Database' => $baseDir . '/app/classes/Database.php',
11+
'App\\Classes\\Mail' => $baseDir . '/app/classes/Mail.php',
1012
'App\\Controllers\\BaseController' => $baseDir . '/app/controllers/BaseController.php',
1113
'App\\Controllers\\IndexController' => $baseDir . '/app/controllers/IndexController.php',
12-
'App\\RouteDispatcher' => $baseDir . '/app/RouteDispatcher.php',
14+
'App\\RouteDispatcher' => $baseDir . '/app/routing/RouteDispatcher.php',
1315
'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php',
1416
'Carbon\\CarbonImmutable' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonImmutable.php',
1517
'Carbon\\CarbonInterface' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonInterface.php',
@@ -387,6 +389,11 @@
387389
'Illuminate\\View\\ViewFinderInterface' => $vendorDir . '/illuminate/view/ViewFinderInterface.php',
388390
'Illuminate\\View\\ViewName' => $vendorDir . '/illuminate/view/ViewName.php',
389391
'Illuminate\\View\\ViewServiceProvider' => $vendorDir . '/illuminate/view/ViewServiceProvider.php',
392+
'PHPMailer\\PHPMailer\\Exception' => $vendorDir . '/phpmailer/phpmailer/src/Exception.php',
393+
'PHPMailer\\PHPMailer\\OAuth' => $vendorDir . '/phpmailer/phpmailer/src/OAuth.php',
394+
'PHPMailer\\PHPMailer\\PHPMailer' => $vendorDir . '/phpmailer/phpmailer/src/PHPMailer.php',
395+
'PHPMailer\\PHPMailer\\POP3' => $vendorDir . '/phpmailer/phpmailer/src/POP3.php',
396+
'PHPMailer\\PHPMailer\\SMTP' => $vendorDir . '/phpmailer/phpmailer/src/SMTP.php',
390397
'Philo\\Blade\\Blade' => $vendorDir . '/philo/laravel-blade/src/Blade.php',
391398
'PhpOption\\LazyOption' => $vendorDir . '/phpoption/phpoption/src/PhpOption/LazyOption.php',
392399
'PhpOption\\None' => $vendorDir . '/phpoption/phpoption/src/PhpOption/None.php',

0 commit comments

Comments
 (0)