Use mailtrap instead of mailjet

This commit is contained in:
Roscoe 2026-02-24 00:22:51 +00:00
commit 2d5f1c13fd
Signed by: RoscoeDaWah
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
7 changed files with 1017 additions and 463 deletions

View file

@ -6,8 +6,10 @@
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Http;
use Illuminate\Validation\ValidationException;
use Mailtrap\MailtrapClient;
use Mailtrap\Mime\MailtrapEmail;
use Symfony\Component\Mime\Address;
use UAParser\Parser;
class GuestbookController extends Controller {
@ -29,31 +31,23 @@ public function show(): View {
*/
public function addEntry(Request $request): RedirectResponse {
$newEntry = GuestbookEntry::create($request);
$response = Http::withBasicAuth(config('services.mailjet.key'), config('services.mailjet.secret'))->post('https://api.mailjet.com/v3.1/send', [
'Messages' => [
[
'From' => [
'Email' => 'wah@wah.moe',
'Name' => 'wah dot moe'
],
'To' => [
[
'Email' => 'roscoe@wah.moe',
'Name' => 'Roscoe D. Wah'
]
],
'Subject' => 'New Guestbook Entry!',
'HtmlPart' => '
$email = (new MailtrapEmail())
->from(new Address("wah@wah.moe", "wah dot moe"))
->to(new Address("roscoe@wah.moe", "Roscoe D. Wah"))
->subject("New Guestbook Entry!")
->html('
<style> td { padding: 5px } </style>
<table border="1">
<tr><td><b>Name:</b></td><td>'.htmlentities($newEntry->name).'</td></tr>
<tr><td><b>IP:</b></td><td>'.$newEntry->ip.'</td></tr>
<tr><td><b>Agent:</b></td><td>'.htmlentities($newEntry->agent).'</td></tr>
<tr><td><b>Message:</b></td><td>'.htmlentities($newEntry->message).'</td></tr>
</table>'
]
]
]);
</table>');
MailtrapClient::initSendingEmails(
apiKey: config('services.mailtrap-sdk.apiKey')
)->send($email);
return back()->with('success', 'Entry submitted successfully!');
}

View file

@ -25,7 +25,7 @@ public static function create(Request $request): GuestbookEntry {
$newEntry = new GuestbookEntry;
$newEntry->name = $request->get('name');
$newEntry->message = $request->get('message');
$newEntry->ip = $request->header('X-Forwarded-For');
$newEntry->ip = $request->header('X-Forwarded-For') ?: $request->ip();
$newEntry->agent = $request->userAgent();
$newEntry->flagged = true;
$newEntry->save();

View file

@ -7,16 +7,19 @@
"require": {
"php": "^8.1",
"ext-exif": "*",
"ext-pdo": "*",
"browner12/helpers": "^3.7",
"guzzlehttp/guzzle": "^7.2",
"guzzlehttp/guzzle": "^7.10",
"intervention/image": "^3.9",
"laravel/framework": "^10.10",
"laravel/tinker": "^2.8",
"php-http/guzzle7-adapter": "^1.1",
"railsware/mailtrap-php": "^3.10",
"scrivo/highlight.php": "v9.18.1.10",
"spatie/laravel-honeypot": "^4.3",
"spatie/laravel-html": "^3.4",
"ua-parser/uap-php": "^3.9.14",
"ext-pdo": "*"
"symfony/mailer": "^6.4",
"ua-parser/uap-php": "^3.9.14"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",

1414
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
return [
'name' => env('APP_NAME', 'wah.moe'),
'version' => '2026.02.12',
'version' => '2026.02.24',
'env' => env('APP_ENV', 'production'),
'debug' => (bool)env('APP_DEBUG', false),
'url' => env('APP_URL', 'http://localhost'),

View file

@ -46,27 +46,8 @@
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
// 'client' => [
// 'timeout' => 5,
// ],
],
'postmark' => [
'transport' => 'postmark',
// 'client' => [
// 'timeout' => 5,
// ],
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
'mailtrap' => [
'transport' => 'mailtrap-sdk'
],
'log' => [

View file

@ -17,9 +17,5 @@
'lastfm' => [
'key' => env('LASTFM_KEY'),
'user' => env('LASTFM_USER'),
],
'mailjet' => [
'key' => env('MAILJET_API'),
'secret' => env('MAILJET_SECRET'),
]
];