From 71e0e6ba7635f3a0cf3a2a1f0b445a44150d46a1 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 1 Sep 2025 21:31:41 +0200 Subject: [PATCH] Email HTML : improve test --- include/lib/sendmail_core.class.php | 2 +- unit-test/include/class/sendmailTest.php | 40 ++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/include/lib/sendmail_core.class.php b/include/lib/sendmail_core.class.php index ef2ac229d..261f89ddb 100644 --- a/include/lib/sendmail_core.class.php +++ b/include/lib/sendmail_core.class.php @@ -174,7 +174,7 @@ class Sendmail_Core $separator_second=md5(rand()); $this->content .= "Content-Type: multipart/alternative; boundary=\"" . $separator_second . "\"".$eol ; $this->content .= "Content-Type: text/plain; charset=UTF-8; format=flowed".$eol; - $this->content .= "Content-Transfer-Encoding: 7bit" . $eol.$eol ; + $this->content .= "Content-Transfer-Encoding: 8bit" . $eol.$eol ; $this->content .= strip_tags($this->message) . $eol ; $this->content.=$eol; $this->content.=$eol; diff --git a/unit-test/include/class/sendmailTest.php b/unit-test/include/class/sendmailTest.php index aa2f10758..ee610882f 100644 --- a/unit-test/include/class/sendmailTest.php +++ b/unit-test/include/class/sendmailTest.php @@ -227,7 +227,7 @@ Consectetur ut cow, non in ipsum brisket dolore short loin. Burgdoggen deserunt $sendmail=new \Sendmail(); $sendmail->mailto(EMAIL_RECIPIENT); $sendmail->set_from("dany@localhost"); - $sendmail->set_subject("Test envoi HTML ".date('d.m.Y h:i')); + $sendmail->set_subject("Test envoi HTML ".date('d.m.Y H:i')); $sendmail->set_format('HTML'); $sendmail->set_message("corps du message @@ -260,7 +260,7 @@ Message en HTML et texte normal $sendmail=new \Sendmail(); $sendmail->mailto(EMAIL_RECIPIENT); $sendmail->set_from("dany@localhost"); - $sendmail->set_subject("Test envoi HTML no format ".date('d.m.Y h:i')); + $sendmail->set_subject("Test envoi HTML no format ".date('d.m.Y H:i')); $sendmail->set_format('HTML'); $sendmail->set_message(" Shouldéré pariaturà turçhducken labore esse. Pancetta burgdoggen ground round nulla commodo cillum rump occaecat leberkas pork loin dolore buffalo tempor. Voluptate flank veniam deserunt chicken, buffalo kielbasa adipisicing short ribs venison non ullamco enim fatback. Ham pariatur lorem turducken consequat. Chicken burgdoggen doner ground round rump officia kielbasa eiusmod meatball, sed jerky mollit. Ut kielbasa t-bone ipsum ex esse, andouille porchetta consectetur do quis ut. Ea andouille sausage, ut lorem ball tip salami esse. @@ -278,4 +278,40 @@ Consectetur ut cow, non in ipsum brisket dolore short loin. Burgdoggen deserunt $this->assertTrue(true); } + + /** + *@testdox send email in HTML and attach file + */ + function testEmailHTMLAttach() + { + + $sendmail=new \Sendmail(); + $sendmail->mailto(EMAIL_RECIPIENT); + $sendmail->set_from("dany@localhost"); + $sendmail->set_subject("Test envoi HTML + file ".date('d.m.Y H:i')); + $sendmail->set_format('HTML'); + $sendmail->set_message("corps du message + +Message en HTML et texte normal + + +

Ceci est un message en HTML

+

GRAS

+

Ceci est un message en HTML

+

ITALIQUE

+

Ceci est un message en HTML

+

COULEUR
+

+

couleur bleue

+ + +"); + $file=new \FileToSend(__DIR__."/data/all_tags.odt"); + $sendmail->add_file($file); + $sendmail->compose(); + $sendmail->send(); + // if not exception thrown , so it works + $this->assertTrue(true); + + } } \ No newline at end of file