diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php
index 23965ce..d340bd2 100644
--- a/app/Http/Controllers/MailController.php
+++ b/app/Http/Controllers/MailController.php
@@ -6,6 +6,7 @@
use Symfony\Component\HttpFoundation\Response;
//use App\Mail\ContactUser;
use App\Mail\SendEmail;
+use App\Models\Users;
//use App\Models\Subscriber;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
@@ -36,8 +37,33 @@ public function send(Request $request)
- public function hello()
- {
- return response()->json('hello');
+ public function hello()
+ {
+ return response()->json('hello');
+ }
+
+ public function contactUser(Request $request)
+ {
+ $senderId = $request->sender_user_id;
+ $receiverId = $request->receiver_user_id;
+ $messageContent = $request->message_content;
+
+ $senderInfo = Users::where('id', '=', $senderId)->select('firstname', 'email_address')->get();
+ $receiverInfo = Users::where('id', '=', $receiverId)->select('firstname', 'email_address')->get();
+
+ foreach ($senderInfo as $si) {
+ $senderName=$si->firstname;
+ $senderMail=$si->email_address;
}
+ foreach ($receiverInfo as $ri) {
+ $receiverName=$ri->firstname;
+ $receiverMail=$ri->email_address;
+ }
+
+
+ $monEmail = 'milekic.alicia@gmail.com';
+ Mail::to($monEmail)->send(new SendEmail($monEmail, $senderName, $senderMail, $receiverName, $receiverMail, $messageContent));
+
+ return response()->json(['status' => 'success', 'message' => 'Email sent Successfully', 'data' => $monEmail]);
+ }
}
diff --git a/app/Mail/SendEmail.php b/app/Mail/SendEmail.php
index b6b71fb..f15825e 100644
--- a/app/Mail/SendEmail.php
+++ b/app/Mail/SendEmail.php
@@ -12,15 +12,25 @@ class SendEmail extends Mailable
use Queueable, SerializesModels;
public $email;
+ public $senderName;
+ public $senderMail;
+ public $receiverName;
+ public $receiverMail;
+ public $messageContent;
/**
* Create a new message instance.
*
* @return void
*/
- public function __construct($email)
+ public function __construct($email, $senderName, $senderMail, $receiverName, $receiverMail, $messageContent)
{
$this->email = $email;
+ $this->senderName = $senderName;
+ $this->senderMail = $senderMail;
+ $this->receiverName = $receiverName;
+ $this->receiverMail = $receiverMail;
+ $this->messageContent = $messageContent;
}
/**
@@ -30,7 +40,8 @@ public function __construct($email)
*/
public function build()
{
- return $this->subject('test, test 1, 2, 1, 2')
+ //"\u{1F913}"
+ return $this->subject('Tu as reçu un nouveau message !')
->markdown('mails.contactUser');
}
}
diff --git a/composer.json b/composer.json
index 7279450..e56455a 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,9 @@
"aws/aws-sdk-php": "^3.222",
"flipbox/lumen-generator": "^9.1",
"guzzlehttp/guzzle": "^7.4",
+ "illuminate/contracts": "^8.83",
"illuminate/mail": "^8.83",
+ "illuminate/view": "^8.83",
"laravel/lumen-framework": "^8.3.1",
"laravelista/lumen-vendor-publish": "^8.0",
"nordsoftware/lumen-cors": "^3.5",
diff --git a/composer.lock b/composer.lock
index 45c43c1..96666e7 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "4a643393990691301a7fb279ed19ae92",
+ "content-hash": "f3dc5fc8ef724b331461909a3ceeb336",
"packages": [
{
"name": "aws/aws-crt-php",
@@ -1520,7 +1520,7 @@
},
{
"name": "illuminate/contracts",
- "version": "v8.83.11",
+ "version": "v8.83.12",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@@ -2524,7 +2524,7 @@
},
{
"name": "illuminate/view",
- "version": "v8.83.11",
+ "version": "v8.83.12",
"source": {
"type": "git",
"url": "https://github.com/illuminate/view.git",
diff --git a/public/meetdevMail.png b/public/meetdevMail.png
new file mode 100644
index 0000000..f15cdb3
Binary files /dev/null and b/public/meetdevMail.png differ
diff --git a/resources/views/mails/contactUser.blade.php b/resources/views/mails/contactUser.blade.php
index 2f068d8..d4cba1b 100644
--- a/resources/views/mails/contactUser.blade.php
+++ b/resources/views/mails/contactUser.blade.php
@@ -1,15 +1,16 @@
@component('mail::message')
-# Introduction
+# Toc toc, on a du courrier pour toi !
-Hello {{ $email }},
+Bonjour {{ $receiverName }},
-The body of your message.
+{{$senderName}} t'a envoyé un message !
-@component('mail::button', ['url' => ''])
-Button Text
+@component('mail::panel')
+{{$messageContent}}
@endcomponent
-Thanks,
-meetDev
-@endcomponent
+Tu peux lui répondre à l'adresse suivante: {{$senderMail}} .
+En te souhaitant une bonne journée,
+L'équipe meetdev
+@endcomponent
diff --git a/resources/views/vendor/mail/html/header.blade.php b/resources/views/vendor/mail/html/header.blade.php
index fa1875c..ff7e79c 100644
--- a/resources/views/vendor/mail/html/header.blade.php
+++ b/resources/views/vendor/mail/html/header.blade.php
@@ -1,6 +1,7 @@
-