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

Add Mailgun API as mail driver

Add Mailgun API as a mail driver.  Can be configured from the System
Settings page.
This commit is contained in:
vincentdh 2016-06-19 13:51:22 -04:00
parent cefa9db856
commit 5875b70496
5 changed files with 49 additions and 16 deletions

View File

@ -20,6 +20,9 @@ MAIL_FROM_ADDRESS
MAIL_FROM_NAME
MAIL_PASSWORD
MAILGUN_DOMAIN=
MAILGUN_SECRET=
#POSTMARK_API_TOKEN=
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_PASSWORD'] = $mail['password'];
$_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 = '';
foreach ($_ENV as $key => $val) {
@ -174,6 +176,8 @@ class AppController extends BaseController
$_ENV['MAIL_FROM_NAME'] = $mail['from']['name'];
$_ENV['MAIL_PASSWORD'] = $mail['password'];
$_ENV['MAIL_FROM_ADDRESS'] = $mail['username'];
$_ENV['MAILGUN_DOMAIN'] = $mail['mailgun_domain'];
$_ENV['MAILGUN_SECRET'] = $mail['mailgun_secret'];
}
$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', ''),
'mailgun' => [
'domain' => '',
'secret' => '',
'domain' => env('MAILGUN_DOMAIN',''),
'secret' => env('MAILGUN_SECRET',''),
],
'mandrill' => [

View File

@ -34,20 +34,28 @@
<h3 class="panel-title">Email Settings</h3>
</div>
<div class="panel-body form-padding-right">
{!! Former::select('mail[driver]')->label('Driver')->options(['smtp' => 'SMTP', 'mail' => 'Mail', 'sendmail' => 'Sendmail'])
->value(isset($_ENV['MAIL_DRIVER']) ? $_ENV['MAIL_DRIVER'] : 'smtp') !!}
{!! 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::select('mail[driver]')->label('Driver')->options(['smtp' => 'SMTP', 'mail' => 'Mail', 'sendmail' => 'Sendmail', 'mailgun' => 'Mailgun'])
->value(isset($_ENV['MAIL_DRIVER']) ? $_ENV['MAIL_DRIVER'] : 'smtp')->setAttributes(['onchange' => 'mailDriverChange()']) !!}
{!! 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')
->value(isset($_ENV['MAIL_USERNAME']) ? $_ENV['MAIL_USERNAME'] : '') !!}
{!! Former::password('mail[password]')->label('Password')
->value(isset($_ENV['MAIL_PASSWORD']) ? $_ENV['MAIL_PASSWORD'] : '') !!}
<div id="standardMailSetup">
{!! 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"/>' ) --}}
</div>
</div>
@ -57,7 +65,8 @@
var db_valid = false
var mail_valid = false
mailDriverChange();
function testDatabase()
{
var data = $("form").serialize() + "&test=db";
@ -78,6 +87,23 @@
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()
{
var data = $("form").serialize() + "&test=mail";