Closed athoik closed 4 weeks ago
We can't reproduce the issue. EML attachment is being successfully received.
The problem may be in your SMTP server.
Great!
Can you please verify that content as well? (eg using md5)
The content is the same as in the sent file.
Once again thanks for your immediate response.
Please note that sending attachment using .txt extension works just fine. Sending attachment using .eml extensions is the one having problem on my side.
Please verify that extension is .eml (not .eml.txt) and if it works on your side, I'll close it!
The extension is .eml
Hi,
I managed to save the mail into EML before sending, using instructions from here: https://pipo.blog/articles/20211203-laravel-mailer-log-eml
diff --git a/app/Listeners/RestartSwiftMailer.php b/app/Listeners/RestartSwiftMailer.php
index 0277bf7b..60f4e90d 100644
--- a/app/Listeners/RestartSwiftMailer.php
+++ b/app/Listeners/RestartSwiftMailer.php
@@ -2,6 +2,10 @@
namespace App\Listeners;
+use Illuminate\Mail\Events\MessageSent;
+use Illuminate\Support\Facades\Storage;
+use Ramsey\Uuid\Uuid;
+
class RestartSwiftMailer
{
@@ -18,7 +22,7 @@ class RestartSwiftMailer
/**
* Handle the event.
*/
- public function handle($event)
+ public function handle(MessageSent $event)
{
// Destroy Swift mailer to make it clean temp files.
// https://github.com/freescout-helpdesk/freescout/issues/2949
@@ -26,5 +30,12 @@ class RestartSwiftMailer
\App::forgetInstance('mailer');
\App::forgetInstance('swift.mailer');
\App::forgetInstance('swift.transport');
+
+ $messageId = $event->data['__laravel_notification_id'] ?? Uuid::uuid4()->toString();
+ Storage::disk('private')->put(
+ sprintf('%s_%s.eml', now()->format('YmdHis'), $messageId),
+ $event->message->toString()
+ );
+
}
}
root@freescout:/var/www/freescout# find | grep eml$ | grep 2024
./storage/app/20240421202704_4ab1f5fd-7bc6-4e20-bb23-c5e5fa505300.eml
./storage/app/20240421202006_d0589427-0d5c-44fa-9049-fd56f7e9c5a7.eml
Indeed the saved email includes the EML attachment and it's not currupted, it has the right size.
Now I need to verify what goes on wire / SMTP server.
socat -v -d -d TCP-LISTEN:25,bind=127.0.0.1,fork TCP:1.2.3.4:25
Socat helped, the attachement goes on wire.
So it's the SMTP server, messing with the EML attachment.
Thanks!
Issue closed.
PHP version: 8.2.18 FreeScout version: 1.8.135 Database: MySQL Are you using CloudFlare: No
Dear Freescout,
I notice that sending EML attachment is problematic. The attachment is received corrupted on recipients.
The following data received, instead of the attachment.
There is no error in logs.
Here is a sample EML (just remove the .txt extension). This_is_a_test_subject.eml.txt
Could you please have a look?
Best Regards, Athanasios