Added option to use reply-to header for replies

This commit is contained in:
Will Browning 2021-02-24 12:18:38 +00:00
parent 9a83bf7c2a
commit 9c60cf6aef
13 changed files with 995 additions and 648 deletions

View file

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UpdateUseReplyToRequest;
class UseReplyToController extends Controller
{
public function update(UpdateUseReplyToRequest $request)
{
if ($request->use_reply_to) {
user()->update(['use_reply_to' => true]);
} else {
user()->update(['use_reply_to' => false]);
}
return back()->with(['status' => $request->use_reply_to ? 'Use Reply To Enabled Successfully' : 'Use Reply To Disabled Successfully']);
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateUseReplyToRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'use_reply_to' => 'required|boolean'
];
}
}

View file

@ -94,7 +94,14 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
*/ */
public function build() public function build()
{ {
// Check if the user is using the old reply-to and from headers
if ($this->user->use_reply_to) {
$this->fromEmail = $this->alias->email;
$replyToEmail = $this->alias->local_part . '+' . Str::replaceLast('@', '=', $this->replyToAddress) . '@' . $this->alias->domain;
} else {
$this->fromEmail = $this->alias->local_part . '+' . Str::replaceLast('@', '=', $this->replyToAddress) . '@' . $this->alias->domain; $this->fromEmail = $this->alias->local_part . '+' . Str::replaceLast('@', '=', $this->replyToAddress) . '@' . $this->alias->domain;
}
$returnPath = $this->alias->email; $returnPath = $this->alias->email;
@ -106,13 +113,13 @@ class ForwardEmail extends Mailable implements ShouldQueue, ShouldBeEncrypted
$this->dkimSigner->ignoreHeader('Return-Path'); $this->dkimSigner->ignoreHeader('Return-Path');
} }
} else { } else {
if (! isset($replyToEmail)) {
$replyToEmail = $this->fromEmail; $replyToEmail = $this->fromEmail;
}
$this->fromEmail = config('mail.from.address'); $this->fromEmail = config('mail.from.address');
$returnPath = config('anonaddy.return_path'); $returnPath = config('anonaddy.return_path');
} }
} else {
$returnPath = 'mailer@'.$this->alias->parentDomain();
} }
$this->email = $this $this->email = $this

View file

@ -33,6 +33,9 @@ class User extends Authenticatable implements MustVerifyEmail
'banner_location', 'banner_location',
'catch_all', 'catch_all',
'bandwidth', 'bandwidth',
'default_alias_domain',
'default_alias_format',
'use_reply_to',
'default_recipient_id', 'default_recipient_id',
'password', 'password',
'two_factor_enabled', 'two_factor_enabled',
@ -67,7 +70,8 @@ class User extends Authenticatable implements MustVerifyEmail
'id' => 'string', 'id' => 'string',
'default_recipient_id' => 'string', 'default_recipient_id' => 'string',
'catch_all' => 'boolean', 'catch_all' => 'boolean',
'two_factor_enabled' => 'boolean' 'two_factor_enabled' => 'boolean',
'use_reply_to' => 'boolean'
]; ];
protected $dates = [ protected $dates = [

111
composer.lock generated
View file

@ -1844,16 +1844,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v8.28.1", "version": "v8.29.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "73dd43d92fcde6c6abc00658ae33391397ca119d" "reference": "d2eba352b3b3a3c515b18c5726b373fe5026733e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/73dd43d92fcde6c6abc00658ae33391397ca119d", "url": "https://api.github.com/repos/laravel/framework/zipball/d2eba352b3b3a3c515b18c5726b373fe5026733e",
"reference": "73dd43d92fcde6c6abc00658ae33391397ca119d", "reference": "d2eba352b3b3a3c515b18c5726b373fe5026733e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1961,7 +1961,7 @@
"phpunit/phpunit": "Required to use assertions and run tests (^8.5.8|^9.3.3).", "phpunit/phpunit": "Required to use assertions and run tests (^8.5.8|^9.3.3).",
"predis/predis": "Required to use the predis connector (^1.1.2).", "predis/predis": "Required to use the predis connector (^1.1.2).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0).", "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0).",
"symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).", "symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).",
"symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).", "symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).",
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).", "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
@ -2008,20 +2008,20 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-02-16T18:07:44+00:00" "time": "2021-02-23T14:27:41+00:00"
}, },
{ {
"name": "laravel/passport", "name": "laravel/passport",
"version": "v10.1.0", "version": "v10.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/passport.git", "url": "https://github.com/laravel/passport.git",
"reference": "c2b93a7d8d93cf303bb1eefbfa5610f084f9bdd4" "reference": "2ed01909228b049f6ea0aa2d4b0ae78d3b27bee3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/passport/zipball/c2b93a7d8d93cf303bb1eefbfa5610f084f9bdd4", "url": "https://api.github.com/repos/laravel/passport/zipball/2ed01909228b049f6ea0aa2d4b0ae78d3b27bee3",
"reference": "c2b93a7d8d93cf303bb1eefbfa5610f084f9bdd4", "reference": "2ed01909228b049f6ea0aa2d4b0ae78d3b27bee3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2040,7 +2040,7 @@
"league/oauth2-server": "^8.2", "league/oauth2-server": "^8.2",
"nyholm/psr7": "^1.3", "nyholm/psr7": "^1.3",
"php": "^7.3|^8.0", "php": "^7.3|^8.0",
"phpseclib/phpseclib": "^2.0", "phpseclib/phpseclib": "^3.0",
"symfony/psr-http-message-bridge": "^2.0" "symfony/psr-http-message-bridge": "^2.0"
}, },
"require-dev": { "require-dev": {
@ -2085,7 +2085,7 @@
"issues": "https://github.com/laravel/passport/issues", "issues": "https://github.com/laravel/passport/issues",
"source": "https://github.com/laravel/passport" "source": "https://github.com/laravel/passport"
}, },
"time": "2020-11-26T07:57:30+00:00" "time": "2021-02-23T20:45:29+00:00"
}, },
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
@ -2276,16 +2276,16 @@
}, },
{ {
"name": "lcobucci/jwt", "name": "lcobucci/jwt",
"version": "4.1.1", "version": "4.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/lcobucci/jwt.git", "url": "https://github.com/lcobucci/jwt.git",
"reference": "7959c5ee8d50e75b8e39ff9e11041208c22a542a" "reference": "c544710aa18e079baf0027ca4c8236913f46945b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/7959c5ee8d50e75b8e39ff9e11041208c22a542a", "url": "https://api.github.com/repos/lcobucci/jwt/zipball/c544710aa18e079baf0027ca4c8236913f46945b",
"reference": "7959c5ee8d50e75b8e39ff9e11041208c22a542a", "reference": "c544710aa18e079baf0027ca4c8236913f46945b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2334,7 +2334,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/lcobucci/jwt/issues", "issues": "https://github.com/lcobucci/jwt/issues",
"source": "https://github.com/lcobucci/jwt/tree/4.1.1" "source": "https://github.com/lcobucci/jwt/tree/4.1.2"
}, },
"funding": [ "funding": [
{ {
@ -2346,7 +2346,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2021-02-16T09:59:04+00:00" "time": "2021-02-19T19:37:15+00:00"
}, },
{ {
"name": "league/commonmark", "name": "league/commonmark",
@ -2905,23 +2905,23 @@
}, },
{ {
"name": "maatwebsite/excel", "name": "maatwebsite/excel",
"version": "3.1.26", "version": "3.1.27",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git", "url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "66f7c9584304ad0b6a267a5d8ffbfa2ff4272e85" "reference": "584d65427eae4de0ba072297c8fac9b0d63dbc37"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/66f7c9584304ad0b6a267a5d8ffbfa2ff4272e85", "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/584d65427eae4de0ba072297c8fac9b0d63dbc37",
"reference": "66f7c9584304ad0b6a267a5d8ffbfa2ff4272e85", "reference": "584d65427eae4de0ba072297c8fac9b0d63dbc37",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"illuminate/support": "5.8.*|^6.0|^7.0|^8.0", "illuminate/support": "5.8.*|^6.0|^7.0|^8.0",
"php": "^7.0|^8.0", "php": "^7.0|^8.0",
"phpoffice/phpspreadsheet": "^1.15" "phpoffice/phpspreadsheet": "^1.16"
}, },
"require-dev": { "require-dev": {
"orchestra/testbench": "^6.0", "orchestra/testbench": "^6.0",
@ -2967,7 +2967,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Maatwebsite/Laravel-Excel/issues", "issues": "https://github.com/Maatwebsite/Laravel-Excel/issues",
"source": "https://github.com/Maatwebsite/Laravel-Excel/tree/3.1.26" "source": "https://github.com/Maatwebsite/Laravel-Excel/tree/3.1.27"
}, },
"funding": [ "funding": [
{ {
@ -2979,7 +2979,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-11-27T16:17:38+00:00" "time": "2021-02-22T16:58:19+00:00"
}, },
{ {
"name": "maennchen/zipstream-php", "name": "maennchen/zipstream-php",
@ -4436,24 +4436,26 @@
}, },
{ {
"name": "phpseclib/phpseclib", "name": "phpseclib/phpseclib",
"version": "2.0.30", "version": "3.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpseclib/phpseclib.git", "url": "https://github.com/phpseclib/phpseclib.git",
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36" "reference": "7c751ea006577e4c2e83326d90c8b1e8c11b8ede"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/136b9ca7eebef78be14abf90d65c5e57b6bc5d36", "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/7c751ea006577e4c2e83326d90c8b1e8c11b8ede",
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36", "reference": "7c751ea006577e4c2e83326d90c8b1e8c11b8ede",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "paragonie/constant_time_encoding": "^1|^2",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
}, },
"require-dev": { "require-dev": {
"phing/phing": "~2.7", "phing/phing": "~2.7",
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4", "phpunit/phpunit": "^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0" "squizlabs/php_codesniffer": "~2.0"
}, },
"suggest": { "suggest": {
@ -4468,7 +4470,7 @@
"phpseclib/bootstrap.php" "phpseclib/bootstrap.php"
], ],
"psr-4": { "psr-4": {
"phpseclib\\": "phpseclib/" "phpseclib3\\": "phpseclib/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -4525,7 +4527,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/phpseclib/phpseclib/issues", "issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/2.0.30" "source": "https://github.com/phpseclib/phpseclib/tree/3.0.5"
}, },
"funding": [ "funding": [
{ {
@ -4541,7 +4543,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2020-12-17T05:42:04+00:00" "time": "2021-02-12T16:18:16+00:00"
}, },
{ {
"name": "pragmarx/google2fa", "name": "pragmarx/google2fa",
@ -9026,16 +9028,16 @@
}, },
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "1.11.1", "version": "1.12.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/annotations.git", "url": "https://github.com/doctrine/annotations.git",
"reference": "ce77a7ba1770462cd705a91a151b6c3746f9c6ad" "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/ce77a7ba1770462cd705a91a151b6c3746f9c6ad", "url": "https://api.github.com/repos/doctrine/annotations/zipball/b17c5014ef81d212ac539f07a1001832df1b6d3b",
"reference": "ce77a7ba1770462cd705a91a151b6c3746f9c6ad", "reference": "b17c5014ef81d212ac539f07a1001832df1b6d3b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9050,11 +9052,6 @@
"phpunit/phpunit": "^7.5 || ^9.1.5" "phpunit/phpunit": "^7.5 || ^9.1.5"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
@ -9095,9 +9092,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/annotations/issues", "issues": "https://github.com/doctrine/annotations/issues",
"source": "https://github.com/doctrine/annotations/tree/1.11.1" "source": "https://github.com/doctrine/annotations/tree/1.12.1"
}, },
"time": "2020-10-26T10:28:16+00:00" "time": "2021-02-21T21:00:45+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
@ -9645,16 +9642,16 @@
}, },
{ {
"name": "mockery/mockery", "name": "mockery/mockery",
"version": "1.4.2", "version": "1.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mockery/mockery.git", "url": "https://github.com/mockery/mockery.git",
"reference": "20cab678faed06fac225193be281ea0fddb43b93" "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/20cab678faed06fac225193be281ea0fddb43b93", "url": "https://api.github.com/repos/mockery/mockery/zipball/d1339f64479af1bee0e82a0413813fe5345a54ea",
"reference": "20cab678faed06fac225193be281ea0fddb43b93", "reference": "d1339f64479af1bee0e82a0413813fe5345a54ea",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9711,9 +9708,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/mockery/mockery/issues", "issues": "https://github.com/mockery/mockery/issues",
"source": "https://github.com/mockery/mockery/tree/master" "source": "https://github.com/mockery/mockery/tree/1.4.3"
}, },
"time": "2020-08-11T18:10:13+00:00" "time": "2021-02-24T09:51:49+00:00"
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
@ -9923,16 +9920,16 @@
}, },
{ {
"name": "phar-io/version", "name": "phar-io/version",
"version": "3.0.4", "version": "3.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phar-io/version.git", "url": "https://github.com/phar-io/version.git",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451" "reference": "bae7c545bef187884426f042434e561ab1ddb182"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451", "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451", "reference": "bae7c545bef187884426f042434e561ab1ddb182",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9968,9 +9965,9 @@
"description": "Library for handling version information and constraints", "description": "Library for handling version information and constraints",
"support": { "support": {
"issues": "https://github.com/phar-io/version/issues", "issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.0.4" "source": "https://github.com/phar-io/version/tree/3.1.0"
}, },
"time": "2020-12-13T23:18:30+00:00" "time": "2021-02-23T14:00:09+00:00"
}, },
{ {
"name": "php-cs-fixer/diff", "name": "php-cs-fixer/diff",

View file

@ -5,9 +5,9 @@ current:
major: 0 major: 0
minor: 7 minor: 7
patch: 0 patch: 0
prerelease: 4-gcd70b89 prerelease: 5-g9a83bf7
buildmetadata: '' buildmetadata: ''
commit: cd70b8 commit: 9a83bf
timestamp: timestamp:
year: 2020 year: 2020
month: 10 month: 10

View file

@ -29,6 +29,7 @@ class UserFactory extends Factory
'bandwidth' => 0, 'bandwidth' => 0,
'catch_all' => 1, 'catch_all' => 1,
'default_recipient_id' => Recipient::factory(), 'default_recipient_id' => Recipient::factory(),
'use_reply_to' => 0,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => Str::random(10), 'remember_token' => Str::random(10),
]; ];

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUseReplyToToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('use_reply_to')->after('default_alias_format')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('use_reply_to');
});
}
}

1318
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -235,6 +235,50 @@
</form> </form>
<form class="pt-16" method="POST" action="{{ route('settings.use_reply_to') }}">
@csrf
<div class="mb-6">
<h3 class="font-bold text-xl">
Use Reply-To Header For Replying
</h3>
<div class="mt-4 w-24 border-b-2 border-grey-200"></div>
<p class="mt-6">This will determine if forwarded emails use the From header or the Reply-To header for sending replies. Some users may find it easier to set up inbox filters having the From: header set as just the alias.
</p>
<p class="mt-4">If enabled, then the <b>From:</b> header will bet set as the alias email e.g. <b>alias{{ '@'.$user->username }}.{{ config('anonaddy.domain') }}</b> instead of the default <b>alias+sender=example.com{{ '@'.$user->username }}.{{ config('anonaddy.domain') }}</b> (this will be set as the Reply-To header instead)</p>
<div class="mt-6 flex flex-wrap mb-4">
<label for="use_reply_to" class="block text-grey-700 text-sm mb-2">
{{ __('Update Use Reply-To') }}:
</label>
<div class="block relative w-full">
<select id="use_reply_to" class="block appearance-none w-full text-grey-700 bg-grey-100 p-3 pr-8 rounded shadow focus:ring" name="use_reply_to" required>
<option value="1" {{ $user->use_reply_to ? 'selected' : '' }}>Enabled</option>
<option value="0" {{ ! $user->use_reply_to ? 'selected' : '' }}>Disabled</option>
</select>
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/></svg>
</div>
</div>
@if ($errors->has('use_reply_to'))
<p class="text-red-500 text-xs italic mt-4">
{{ $errors->first('use_reply_to') }}
</p>
@endif
</div>
</div>
<button type="submit" class="bg-cyan-400 w-full hover:bg-cyan-300 text-cyan-900 font-bold py-3 px-4 rounded focus:outline-none">
Update Use Reply-To
</button>
</form>
<form id="update-password" method="POST" action="{{ route('settings.password') }}" class="pt-16"> <form id="update-password" method="POST" action="{{ route('settings.password') }}" class="pt-16">
@csrf @csrf

View file

@ -72,6 +72,8 @@ Route::group([
Route::post('/catch-all', 'CatchAllController@update')->name('settings.catch_all'); Route::post('/catch-all', 'CatchAllController@update')->name('settings.catch_all');
Route::post('/use-reply-to', 'UseReplyToController@update')->name('settings.use_reply_to');
Route::post('/password', 'PasswordController@update')->name('settings.password'); Route::post('/password', 'PasswordController@update')->name('settings.password');
Route::delete('/browser-sessions', 'BrowserSessionController@destroy')->name('browser-sessions.destroy'); Route::delete('/browser-sessions', 'BrowserSessionController@destroy')->name('browser-sessions.destroy');

View file

@ -1000,4 +1000,37 @@ class ReceiveEmailTest extends TestCase
return $mail->hasTo($recipient->email); return $mail->hasTo($recipient->email);
}); });
} }
/** @test */
public function it_can_forward_email_using_old_reply_to_and_from_headers()
{
Mail::fake();
Mail::assertNothingSent();
$this->user->update(['use_reply_to' => true]);
$this->assertTrue($this->user->use_reply_to);
$this->artisan(
'anonaddy:receive-email',
[
'file' => base_path('tests/emails/email.eml'),
'--sender' => 'will@anonaddy.com',
'--recipient' => ['ebay@johndoe.anonaddy.com'],
'--local_part' => ['ebay'],
'--extension' => [''],
'--domain' => ['johndoe.anonaddy.com'],
'--size' => '1346'
]
)->assertExitCode(0);
$this->assertEquals(1, $this->user->aliases()->count());
Mail::assertQueued(ForwardEmail::class, function ($mail) {
$mail->build();
return $mail->hasTo($this->user->email) && $mail->hasFrom('ebay@johndoe.anonaddy.com') && $mail->hasReplyTo('ebay+will=anonaddy.com@johndoe.anonaddy.com');
});
}
} }

View file

@ -238,6 +238,34 @@ class SettingsTest extends TestCase
$this->assertFalse($this->user->catch_all); $this->assertFalse($this->user->catch_all);
} }
/** @test */
public function user_can_enable_use_reply_to()
{
$this->assertFalse($this->user->use_reply_to);
$response = $this->post('/settings/use-reply-to/', [
'use_reply_to' => true
]);
$response->assertStatus(302);
$this->assertTrue($this->user->use_reply_to);
}
/** @test */
public function user_can_disable_use_reply_to()
{
$this->user->update(['use_reply_to' => true]);
$this->assertTrue($this->user->use_reply_to);
$response = $this->post('/settings/use-reply-to/', [
'use_reply_to' => false
]);
$response->assertStatus(302);
$this->assertFalse($this->user->use_reply_to);
}
/** @test */ /** @test */
public function user_can_delete_account() public function user_can_delete_account()
{ {