Skip to content

Commit 1eef908

Browse files
author
rajakodings
committed
init
0 parents  commit 1eef908

File tree

10 files changed

+234
-0
lines changed

10 files changed

+234
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor/
2+
/.idea
3+
_config.yml
4+
composer.lock

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Crocodic Studio
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Email Tester For Laravel
2+
3+
Debugging send the email is never been easy. With this library you can debug and check your email smtp problem.
4+
5+
## How to install
6+
Install this library with command :
7+
8+
<code>composer require crocodicstudio/emailtester</code>
9+
10+
Recommended laravel version 5.7 up . If you use 5.4 or bellow you have to add service provider manually
11+
12+
<code>crocodicstudio/emailtester/EmailTesterServiceProvider::class</code> to config/app.php (Providers section)
13+
14+
## How to use
15+
16+
Just visit the url /email-tester at the browser.
17+
18+
# How to disable
19+
20+
To disable this email tester, you can add <code>EMAIL_TESTER=false</code> to your .env

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "crocodicstudio/email-tester",
3+
"description": "SMTP Email tester and debug for Laravel",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Ferry Ariawan",
9+
"email": "ferry@crocodic.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"require": {
14+
"php": ">5.6",
15+
"laravel/laravel":"^5.4"
16+
},
17+
"autoload": {
18+
"psr-0": {
19+
"crocodicstudio\\emailtester": "src/"
20+
}
21+
},
22+
"extra": {
23+
"laravel": {
24+
"providers": [
25+
"crocodicstudio\\emailtester\\EmailTesterServiceProvider"
26+
]
27+
}
28+
}
29+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace crocodicstudio\emailtester\controllers;
4+
5+
use Illuminate\Routing\Controller as BaseController;
6+
use Illuminate\Support\Facades\Config;
7+
use Illuminate\Support\Facades\Mail;
8+
9+
class EmailTesterController extends BaseController
10+
{
11+
12+
public function getIndex()
13+
{
14+
return view("emailtester::email_form");
15+
}
16+
17+
public function postSend()
18+
{
19+
Config::set('mail.driver',request("driver"));
20+
Config::set('mail.host',request('hostname'));
21+
Config::set('mail.port', request('port'));
22+
if(request('encryption')) {
23+
Config::set('mail.encryption',request('encryption'));
24+
}
25+
26+
Config::set('mail.username',request('username'));
27+
Config::set('mail.password',request('password'));
28+
29+
$logger = new \Swift_Plugins_Loggers_ArrayLogger();
30+
Mail::getSwiftMailer()->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
31+
32+
$data['debug'] = "";
33+
34+
try{
35+
Mail::send("crudbooster::emails.blank",['content'=>request('content')],function($message) {
36+
$message->priority(1);
37+
$message->to(request('to'));
38+
$message->from("email-tester@".$_SERVER['SERVER_NAME'],"Email Tester Agent");
39+
$message->subject(request("subject"));
40+
});
41+
}catch(\Swift_TransportException $e) {
42+
// $data['debug'] .= $e->getMessage();
43+
}
44+
45+
46+
$data['debug'] .= $logger->dump();
47+
}
48+
}

src/EmailTesterServiceProvider.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace crocodicstudio\emailtester;
3+
4+
use Illuminate\Support\ServiceProvider;
5+
6+
class EmailTesterServiceProvider extends ServiceProvider
7+
{
8+
/**
9+
* Bootstrap the application services.
10+
*
11+
* @return void
12+
*/
13+
14+
public function boot()
15+
{
16+
$this->loadViewsFrom(__DIR__.'/Views', 'emailtester');
17+
18+
require __DIR__.'/Routes/route.php';
19+
}
20+
21+
/**
22+
* Register the application services.
23+
*
24+
* @return void
25+
*/
26+
public function register()
27+
{
28+
require __DIR__.'/Helpers/Helper.php';
29+
30+
31+
$this->app->singleton('emailtester', function () {
32+
return true;
33+
});
34+
}
35+
36+
}

src/Helpers/Helper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Crocodicstudio\Cbmodel\Helpers;
4+
5+
use Illuminate\Support\Facades\DB;
6+
7+
class Helper
8+
{
9+
10+
}

src/Routes/route.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
5+
if(env("EMAIL_TESTER", true)===true) {
6+
Route::group([
7+
'middleware' => ['web'],
8+
'prefix' => "/",
9+
'namespace' => 'crocodicstudio\emailtester\controllers',
10+
], function () {
11+
Route::get("email-tester", "EmailTesterController@getIndex");
12+
Route::post("email-tester", "EmailTesterController@postSend");
13+
});
14+
}

src/Views/blank.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{!! $content !!}

src/Views/email_form.blade.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<html>
2+
<head>
3+
<title>Email Tester For Laravel</title>
4+
</head>
5+
<body>
6+
<h2>Email Tester For Laravel</h2>
7+
<form action="" method="post">
8+
{!! csrf_field() !!}
9+
<table width="500px" border="1px">
10+
<tr>
11+
<td>Driver</td><td><input type="text" name="driver" size="90" value="{{ request('driver')?:'smtp' }}" required ></td>
12+
</tr>
13+
<tr>
14+
<td>Hostname</td><td><input type="text" name="hostname" size="90" value="{{ request('hostname') }}" required ></td>
15+
</tr>
16+
<tr>
17+
<td>Username</td><td><input type="text" name="username" size="90" value="{{ request('username') }}" required ></td>
18+
</tr>
19+
<tr>
20+
<td>Password</td><td><input type="text" name="password" size="90" value="{{ request('password') }}" required ></td>
21+
</tr>
22+
<tr>
23+
<td>Port</td><td><input type="text" name="port" size="40" value="{{ request('port')?:587 }}" required ></td>
24+
</tr>
25+
<tr>
26+
<td>Encryption</td><td><input type="text" name="encryption" size="40" value="{{ request('encryption')?:"tls" }}" ></td>
27+
</tr>
28+
<tr>
29+
<td>To</td><td><input type="text" name="to" size="90" value="{{ request('to') }}" required ></td>
30+
</tr>
31+
<tr>
32+
<td>Subject</td><td><input type="text" name="subject" size="90" value="{{ request('subject')?:'Thank you for using this email tester' }}" required ></td>
33+
</tr>
34+
<tr>
35+
<td>Message</td><td><input type="text" name="content" size="90" value="{{ request('content')?:'Hi there, Congratulation the email has been received successfully' }}" required ></td>
36+
</tr>
37+
<tr>
38+
<td>&nbsp;</td><td><input type="submit" value="Submit"></td>
39+
</tr>
40+
</table>
41+
</form>
42+
43+
@if(isset($debug))
44+
<pre>
45+
{!! $debug !!}
46+
</pre>
47+
@endif
48+
</body>
49+
</html>
50+
51+

0 commit comments

Comments
 (0)