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!');
}