# Mail function and php version

**URL:** <https://kanboard.discourse.group/t/mail-function-and-php-version/2364>\
**Category:** Installation Issues\
**Created:** [September 9, 2022, 11:10am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364 "2022-09-09T11:10:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://kanboard.discourse.group/u/steff)\
**Post date:** [September 9, 2022, 11:10am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/1 "2022-09-09T11:10:11Z")

</div>

I recently switched from php 7.4. to php 8.0 (with KB version 1.2.23). I use a shared hosting from Host-Europe. When I use the “Send task by email” function, I get an email where the text contains raw HTML that is not parsed.

I found out that the email header contains the FROM: and DATE: twice, e.g.

```nohighlight
To: "forname surname " <user@domain.tld>
Subject: TEST
Message-ID: <f7f5a1cc4545ae2c2a88a73f6edf0cf4@assets.domain.tld>
Date: Fri, 09 Sep 2022 12:15:57 +0200
From: via Kanboard <noreply@domain.tld>
Reply-To: user@domain.tld
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Auto-Submitted: auto-generated
From: noreply@domain.tld
Date: Fri, 09 Sep 2022 12:15:57 +0200

```

When I switch the php version back, everything is fine. Does anyone know the problem?

Steff

---

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://kanboard.discourse.group/u/steff)\
**Post date:** [December 22, 2022, 10:34am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/2 "2022-12-22T10:34:21Z")

</div>

I found out that some header entries (Date:, From:, Reply-To:, MIME-Version:, Content-Type:, Content-Transfer-Encoding:) have a space character at the first column and this cause the problem.

> To: "forname surname " \<mailaddress\>  
> Subject: TEST  
> Message-ID: \<messageID\>  
> ⚠Date: Fri, 09 Sep 2022 12:15:57 +0200  
> ⚠From: via Kanboard \<mailaddress\>  
> ⚠Reply-To: user@domain.tld  
> ⚠MIME-Version: 1.0  
> ⚠Content-Type: text/html; charset=utf-8  
> ⚠Content-Transfer-Encoding: quoted-printable  
> Auto-Submitted: auto-generated  
> From: noreply@domain.tld  
> Date: Fri, 09 Sep 2022 12:15:57 +0200

Where is the header generated?

---

<div class="post-metadata">

**Author:** ![steff](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@steff](https://kanboard.discourse.group/u/steff)\
**Post date:** [December 22, 2022, 11:53am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/3 "2022-12-22T11:53:36Z")

</div>

Problem solved: the PHP constant PHP\_EOL has changed between php 7.4. and php 8.x.

```auto
kanboard-1.2.23/libs/swiftmailer/classes/Swift/Transport/MailTransport.php

```

```php
162 if ("\r\n" != PHP_EOL) {
163 // Non-windows (not using SMTP)
164 $headers = str_replace("\r\n", PHP_EOL, $headers);
165 $subject = str_replace("\r\n", PHP_EOL, $subject);
166 $body = str_replace("\r\n", PHP_EOL, $body);
167 $to = str_replace("\r\n", PHP_EOL, $to);
168 } else {

```

changed to

```php
162 if ("\r\n" != PHP_EOL) {
163 // Non-windows (not using SMTP)
164 $headers = str_replace("\r\n", "\r\n", $headers);
165 $subject = str_replace("\r\n", "\r\n", $subject);
166 $body = str_replace("\r\n", "\r\n", $body);
167 $to = str_replace("\r\n", "\r\n", $to);
168 } else {

```

Now, the mails will be parsed. This ist as swiftmailer problem, btw. this class marked as deprecated.

---

<div class="post-metadata">

**Author:** ![alfredb](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/alfredb/32/1051_2.png) [@alfredb](https://kanboard.discourse.group/u/alfredb)\
**Post date:** [April 23, 2025, 6:27pm UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/5 "2025-04-23T18:27:52Z")

</div>

> [@Yumiko-zhang](#):
>
> `smtp.163.com`

Your config looks reasonable. If your Kanboard can reach _[smtp.163.com](http://smtp.163.com)_, and you have the correct username & password, the mailing should work.

Are you sure that [smtp.163.com](http://smtp.163.com) accepts connection on port 587? My test says _no_, but on port 25 you’ll get an answer. 😉 It’s up to you to clarify this.

---

<div class="post-metadata">

**Author:** ![Yumiko-zhang](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/yumiko-zhang/32/2049_2.png) [@Yumiko-zhang](https://kanboard.discourse.group/u/Yumiko-zhang)\
**Post date:** [April 24, 2025, 1:24am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/6 "2025-04-24T01:24:14Z")

</div>

Hi, good to get your reply again. 😊 I checked the 163 email page and it actually accepts SSL connection. I think that means [smtp.163.com](http://smtp.163.com) accepts connetion on port 587. Is this right?

 ![图片](https://global.discourse-cdn.com/free1/uploads/kanboard1/original/2X/5/59740146a4a3b16b1053a8de5524e82b469cf48c.png)

---

<div class="post-metadata">

**Author:** ![Yumiko-zhang](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/yumiko-zhang/32/2049_2.png) [@Yumiko-zhang](https://kanboard.discourse.group/u/Yumiko-zhang)\
**Post date:** [April 24, 2025, 3:26am UTC](https://kanboard.discourse.group/t/mail-function-and-php-version/2364/7 "2025-04-24T03:26:05Z")

</div>

Hi, alfredb. I just changed the port from 587 to 465 and the `MAIL_SMTP_ENCRYPTION` from tls to ssl. Then it works, I received the email successfully. BTW, thanks for your kind advice. 😊
