Add reply-to config setting

This commit is contained in:
snipe 2016-09-20 07:20:10 -07:00
parent 1e4e9dd3d7
commit bd5e6d8551
11 changed files with 50 additions and 5 deletions

View file

@ -31,6 +31,8 @@ MAIL_PASSWORD=YOURPASSWORD
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
MAIL_FROM_ADDR=you@example.com MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME='Snipe-IT' MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=you@example.com
MAIL_REPLYTO_NAME='Snipe-IT'
# -------------------------------------------- # --------------------------------------------

View file

@ -100,16 +100,20 @@ class SendExpirationAlerts extends Command
if (count($expiring_assets) > 0) { if (count($expiring_assets) > 0) {
$this->info('Report sent to '.Setting::getSettings()->alert_email);
\Mail::send('emails.expiring-assets-report', $asset_data, function ($m) { \Mail::send('emails.expiring-assets-report', $asset_data, function ($m) {
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Expiring Assets Report'); $m->subject('Expiring Assets Report');
}); });
} }
if (count($expiring_licenses) > 0) { if (count($expiring_licenses) > 0) {
$this->info('Report sent to '.Setting::getSettings()->alert_email);
\Mail::send('emails.expiring-licenses-report', $license_data, function ($m) { \Mail::send('emails.expiring-licenses-report', $license_data, function ($m) {
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Expiring Licenses Report'); $m->subject('Expiring Licenses Report');
}); });

View file

@ -50,6 +50,7 @@ class SendInventoryAlerts extends Command
if (count($data['data']) > 0) { if (count($data['data']) > 0) {
\Mail::send('emails.low-inventory', $data, function ($m) { \Mail::send('emails.low-inventory', $data, function ($m) {
$m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name); $m->to(explode(',', Setting::getSettings()->alert_email), Setting::getSettings()->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Low Inventory Report'); $m->subject('Low Inventory Report');
}); });

View file

@ -365,6 +365,7 @@ class AccessoriesController extends Controller
Mail::send('emails.accept-accessory', $data, function ($m) use ($user) { Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Confirm accessory delivery'); $m->subject('Confirm accessory delivery');
}); });
} }
@ -483,6 +484,7 @@ class AccessoriesController extends Controller
Mail::send('emails.checkin-asset', $data, function ($m) use ($user) { Mail::send('emails.checkin-asset', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Confirm Accessory Checkin'); $m->subject('Confirm Accessory Checkin');
}); });
} }

View file

@ -365,6 +365,7 @@ class ConsumablesController extends Controller
Mail::send('emails.accept-asset', $data, function ($m) use ($user) { Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Confirm consumable delivery'); $m->subject('Confirm consumable delivery');
}); });
} }

View file

@ -147,6 +147,7 @@ class SettingsController extends Controller
try { try {
Mail::send('emails.test', [], function ($m) { Mail::send('emails.test', [], function ($m) {
$m->to(config('mail.from.address'), config('mail.from.name')); $m->to(config('mail.from.address'), config('mail.from.name'));
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Test Email from Snipe-IT'); $m->subject('Test Email from Snipe-IT');
}); });
return 'success'; return 'success';
@ -199,6 +200,7 @@ class SettingsController extends Controller
if (Input::get('email_creds')=='1') { if (Input::get('email_creds')=='1') {
Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) { Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
$m->to($data['email'], $data['first_name']); $m->to($data['email'], $data['first_name']);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Your Snipe-IT credentials'); $m->subject('Your Snipe-IT credentials');
}); });
} }

View file

@ -157,6 +157,7 @@ class UsersController extends Controller
Mail::send('emails.send-login', $data, function ($m) use ($user) { Mail::send('emails.send-login', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Welcome ' . $user->first_name); $m->subject('Welcome ' . $user->first_name);
}); });
} }
@ -209,6 +210,7 @@ class UsersController extends Controller
Mail::send('emails.send-login', $data, function ($m) use ($user) { Mail::send('emails.send-login', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Welcome ' . $user->first_name); $m->subject('Welcome ' . $user->first_name);
}); });
} }
@ -533,7 +535,7 @@ class UsersController extends Controller
$logaction->item_id = $license->id; $logaction->item_id = $license->id;
$logaction->item_type = License::class; $logaction->item_type = License::class;
$logaction->target_id = $license->assigned_to; $logaction->target_id = $license->assigned_to;
$logaction->target_type = User::class; $logaction->target_type = User::class;
$logaction->user_id = Auth::user()->id; $logaction->user_id = Auth::user()->id;
$logaction->note = 'Bulk checkin license and delete user'; $logaction->note = 'Bulk checkin license and delete user';
$logaction->logaction('checkin from'); $logaction->logaction('checkin from');
@ -832,6 +834,7 @@ class UsersController extends Controller
if ($newuser['email']) { if ($newuser['email']) {
Mail::send('emails.send-login', $data, function ($m) use ($newuser) { Mail::send('emails.send-login', $data, function ($m) use ($newuser) {
$m->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']); $m->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Welcome ' . $newuser['first_name']); $m->subject('Welcome ' . $newuser['first_name']);
}); });
} }

View file

@ -126,6 +126,7 @@ class ViewAssetsController extends Controller
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) { if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
Mail::send('emails.asset-canceled', $data, function ($m) use ($user, $settings) { Mail::send('emails.asset-canceled', $data, function ($m) use ($user, $settings) {
$m->to(explode(',', $settings->alert_email), $settings->site_name); $m->to(explode(',', $settings->alert_email), $settings->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Item Request Canceled'); $m->subject('Item Request Canceled');
}); });
} }
@ -159,6 +160,7 @@ class ViewAssetsController extends Controller
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) { if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) { Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) {
$m->to(explode(',', $settings->alert_email), $settings->site_name); $m->to(explode(',', $settings->alert_email), $settings->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Item Requested'); $m->subject('Item Requested');
}); });
} }
@ -222,6 +224,7 @@ class ViewAssetsController extends Controller
if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) { if (($settings->alert_email!='') && ($settings->alerts_enabled=='1') && (!config('app.lock_passwords'))) {
Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) { Mail::send('emails.asset-requested', $data, function ($m) use ($user, $settings) {
$m->to(explode(',', $settings->alert_email), $settings->site_name); $m->to(explode(',', $settings->alert_email), $settings->site_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Asset Requested'); $m->subject('Asset Requested');
}); });
} }
@ -311,7 +314,7 @@ class ViewAssetsController extends Controller
// Redirect to the asset management page // Redirect to the asset management page
return redirect()->to('account/view-assets')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->to('account/view-assets')->with('error', trans('admin/hardware/message.does_not_exist'));
} }
if ($findlog->accepted_id!='') { if ($findlog->accepted_id!='') {
// Redirect to the asset management page // Redirect to the asset management page

View file

@ -152,6 +152,7 @@ class Asset extends Depreciable
\Mail::send('emails.accept-asset', $data, function ($m) use ($user) { \Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name); $m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject('Confirm asset delivery'); $m->subject('Confirm asset delivery');
}); });
} }
@ -577,12 +578,12 @@ public function checkin_email()
public function scopeAssetsByLocation($query, $location) public function scopeAssetsByLocation($query, $location)
{ {
return $query->where(function ($query) use ($location) { return $query->where(function ($query) use ($location) {
$query->whereHas('assigneduser', function ($query) use ($location) { $query->whereHas('assigneduser', function ($query) use ($location) {
$query->where('users.location_id', '=', $location->id); $query->where('users.location_id', '=', $location->id);
})->orWhere(function ($query) use ($location) { })->orWhere(function ($query) use ($location) {
$query->where('assets.rtd_location_id', '=', $location->id); $query->where('assets.rtd_location_id', '=', $location->id);
$query->whereNull('assets.assigned_to'); $query->whereNull('assets.assigned_to');
}); });

View file

@ -3,6 +3,12 @@
return [ return [
/* /*
| ***************************************************************************
| DO NOT MAKE CHANGES DIRECTLY TO THIS FILE.
|
| Instead use your .env file to set your application configuration settings.
| See https://snipe-it.readme.io/docs/configuration for more info.
|
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Mail Driver | Mail Driver
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -11,6 +17,7 @@ return [
| sending of e-mail. You may specify which one you're using throughout | sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail. | your application here. By default, Laravel is setup for SMTP mail.
| |
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "ses", "log" | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "ses", "log"
| |
*/ */
@ -56,6 +63,23 @@ return [
'from' => ['address' => env('MAIL_FROM_ADDR', null), 'name' => env('MAIL_FROM_NAME', null)], 'from' => ['address' => env('MAIL_FROM_ADDR', null), 'name' => env('MAIL_FROM_NAME', null)],
/*
|--------------------------------------------------------------------------
| Global "Reply-To" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to have a different "Reply-to"
| address than the "From" address. If this is left blank, the application will use
| your MAIL_FROM information.
|
*/
'reply_to' => [
'address' => env('MAIL_REPLYTO_ADDR', env('MAIL_FROM_ADDR', null)),
'name' => env('MAIL_REPLYTO_NAME', env('MAIL_FROM_NAME', null))
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| E-Mail Encryption Protocol | E-Mail Encryption Protocol

View file

@ -14,6 +14,8 @@ MAIL_ENV_FROM_NAME=Brady Wetherington
MAIL_ENV_ENCRYPTION=tcp MAIL_ENV_ENCRYPTION=tcp
MAIL_ENV_USERNAME=uberbrady@gmail.com MAIL_ENV_USERNAME=uberbrady@gmail.com
MAIL_ENV_PASSWORD=N7AqLufTZMULWHWYwJ0ZCw MAIL_ENV_PASSWORD=N7AqLufTZMULWHWYwJ0ZCw
MAIL_ENV_REPLYTO_ADDR=you@example.com
MAIL_ENV_REPLYTO_NAME='Snipe-IT'
#SNIPE-IT Variables #SNIPE-IT Variables
APP_ENV=develop APP_ENV=develop