1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Merge pull request #923 from vincentdh/develop

Add Mailgun API in mail drivers
This commit is contained in:
Hillel Coren 2016-07-03 11:58:24 +03:00 committed by GitHub
commit f9aee23de8
5 changed files with 49 additions and 16 deletions

View File

@ -19,6 +19,9 @@ MAIL_FROM_ADDRESS
MAIL_FROM_NAME MAIL_FROM_NAME
MAIL_PASSWORD MAIL_PASSWORD
MAILGUN_DOMAIN=
MAILGUN_SECRET=
#POSTMARK_API_TOKEN= #POSTMARK_API_TOKEN=
PHANTOMJS_CLOUD_KEY='a-demo-key-with-low-quota-per-ip-address' PHANTOMJS_CLOUD_KEY='a-demo-key-with-low-quota-per-ip-address'

View File

@ -100,6 +100,8 @@ class AppController extends BaseController
$_ENV['MAIL_FROM_NAME'] = $mail['from']['name']; $_ENV['MAIL_FROM_NAME'] = $mail['from']['name'];
$_ENV['MAIL_PASSWORD'] = $mail['password']; $_ENV['MAIL_PASSWORD'] = $mail['password'];
$_ENV['PHANTOMJS_CLOUD_KEY'] = 'a-demo-key-with-low-quota-per-ip-address'; $_ENV['PHANTOMJS_CLOUD_KEY'] = 'a-demo-key-with-low-quota-per-ip-address';
$_ENV['MAILGUN_DOMAIN'] = $mail['mailgun_domain'];
$_ENV['MAILGUN_SECRET'] = $mail['mailgun_secret'];
$config = ''; $config = '';
foreach ($_ENV as $key => $val) { foreach ($_ENV as $key => $val) {
@ -174,6 +176,8 @@ class AppController extends BaseController
$_ENV['MAIL_FROM_NAME'] = $mail['from']['name']; $_ENV['MAIL_FROM_NAME'] = $mail['from']['name'];
$_ENV['MAIL_PASSWORD'] = $mail['password']; $_ENV['MAIL_PASSWORD'] = $mail['password'];
$_ENV['MAIL_FROM_ADDRESS'] = $mail['username']; $_ENV['MAIL_FROM_ADDRESS'] = $mail['username'];
$_ENV['MAILGUN_DOMAIN'] = $mail['mailgun_domain'];
$_ENV['MAILGUN_SECRET'] = $mail['mailgun_secret'];
} }
$config = ''; $config = '';

View File

@ -80,7 +80,7 @@ return [
| |
*/ */
'username' => env('MAIL_USERNAME'), 'username' => env('MAIL_USERNAME', ''),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -93,7 +93,7 @@ return [
| |
*/ */
'password' => env('MAIL_PASSWORD'), 'password' => env('MAIL_PASSWORD', ''),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -17,8 +17,8 @@ return [
'postmark' => env('POSTMARK_API_TOKEN', ''), 'postmark' => env('POSTMARK_API_TOKEN', ''),
'mailgun' => [ 'mailgun' => [
'domain' => '', 'domain' => env('MAILGUN_DOMAIN',''),
'secret' => '', 'secret' => env('MAILGUN_SECRET',''),
], ],
'mandrill' => [ 'mandrill' => [

View File

@ -34,20 +34,28 @@
<h3 class="panel-title">Email Settings</h3> <h3 class="panel-title">Email Settings</h3>
</div> </div>
<div class="panel-body form-padding-right"> <div class="panel-body form-padding-right">
{!! Former::select('mail[driver]')->label('Driver')->options(['smtp' => 'SMTP', 'mail' => 'Mail', 'sendmail' => 'Sendmail']) {!! Former::select('mail[driver]')->label('Driver')->options(['smtp' => 'SMTP', 'mail' => 'Mail', 'sendmail' => 'Sendmail', 'mailgun' => 'Mailgun'])
->value(isset($_ENV['MAIL_DRIVER']) ? $_ENV['MAIL_DRIVER'] : 'smtp') !!} ->value(isset($_ENV['MAIL_DRIVER']) ? $_ENV['MAIL_DRIVER'] : 'smtp')->setAttributes(['onchange' => 'mailDriverChange()']) !!}
{!! Former::text('mail[host]')->label('Host')
->value(isset($_ENV['MAIL_HOST']) ? $_ENV['MAIL_HOST'] : '') !!}
{!! Former::text('mail[port]')->label('Port')
->value(isset($_ENV['MAIL_PORT']) ? $_ENV['MAIL_PORT'] : '587') !!}
{!! Former::select('mail[encryption]')->label('Encryption')->options(['tls' => 'TLS', 'ssl' => 'SSL'])
->value(isset($_ENV['MAIL_ENCRYPTION']) ? $_ENV['MAIL_ENCRYPTION'] : 'tls') !!}
{!! Former::text('mail[from][name]')->label('From Name') {!! Former::text('mail[from][name]')->label('From Name')
->value(isset($_ENV['MAIL_FROM_NAME']) ? $_ENV['MAIL_FROM_NAME'] : '') !!} ->value(isset($_ENV['MAIL_FROM_NAME']) ? $_ENV['MAIL_FROM_NAME'] : '') !!}
{!! Former::text('mail[username]')->label('Email') {!! Former::text('mail[username]')->label('Email')
->value(isset($_ENV['MAIL_USERNAME']) ? $_ENV['MAIL_USERNAME'] : '') !!} ->value(isset($_ENV['MAIL_USERNAME']) ? $_ENV['MAIL_USERNAME'] : '') !!}
{!! Former::password('mail[password]')->label('Password') <div id="standardMailSetup">
->value(isset($_ENV['MAIL_PASSWORD']) ? $_ENV['MAIL_PASSWORD'] : '') !!} {!! Former::text('mail[host]')->label('Host')
->value(isset($_ENV['MAIL_HOST']) ? $_ENV['MAIL_HOST'] : '') !!}
{!! Former::text('mail[port]')->label('Port')
->value(isset($_ENV['MAIL_PORT']) ? $_ENV['MAIL_PORT'] : '587') !!}
{!! Former::select('mail[encryption]')->label('Encryption')->options(['tls' => 'TLS', 'ssl' => 'SSL'])
->value(isset($_ENV['MAIL_ENCRYPTION']) ? $_ENV['MAIL_ENCRYPTION'] : 'tls') !!}
{!! Former::password('mail[password]')->label('Password')
->value(isset($_ENV['MAIL_PASSWORD']) ? $_ENV['MAIL_PASSWORD'] : '') !!}
</div>
<div id="mailgunMailSetup">
{!! Former::text('mail[mailgun_domain]')->label('Mailgun Domain')
->value(isset($_ENV['MAILGUN_DOMAIN']) ? $_ENV['MAILGUN_DOMAIN'] : '') !!}
{!! Former::text('mail[mailgun_secret]')->label('Mailgun Private Key')
->value(isset($_ENV['MAILGUN_SECRET']) ? $_ENV['MAILGUN_SECRET'] : '') !!}
</div>
{{-- Former::actions( Button::primary('Send test email')->small()->withAttributes(['onclick' => 'testMail()']), '&nbsp;&nbsp;<span id="mailTestResult"/>' ) --}} {{-- Former::actions( Button::primary('Send test email')->small()->withAttributes(['onclick' => 'testMail()']), '&nbsp;&nbsp;<span id="mailTestResult"/>' ) --}}
</div> </div>
</div> </div>
@ -57,7 +65,8 @@
var db_valid = false var db_valid = false
var mail_valid = false var mail_valid = false
mailDriverChange();
function testDatabase() function testDatabase()
{ {
var data = $("form").serialize() + "&test=db"; var data = $("form").serialize() + "&test=db";
@ -78,6 +87,23 @@
return db_valid; return db_valid;
} }
function mailDriverChange() {
if ($("select[name='mail[driver]'").val() == 'mailgun') {
$("#standardMailSetup").hide();
$("#standardMailSetup").children('select,input').prop('disabled',true);
$("#mailgunMailSetup").show();
$("#mailgunMailSetup").children('select,input').prop('disabled',false);
} else {
$("#standardMailSetup").show();
$("#standardMailSetup").children('select,input').prop('disabled',false);
$("#mailgunMailSetup").hide();
$("#mailgunMailSetup").children('select,input').prop('disabled',true);
}
}
function testMail() function testMail()
{ {
var data = $("form").serialize() + "&test=mail"; var data = $("form").serialize() + "&test=mail";