PHP Email emails not sent/received by Kanboard

I am not getting any emails from Kanboard, even though if I send a comment or a card by email, Kanboard gives a message saying it was successfully sent.

I have tested that my server will successfully send an email via PHP mail() with a test php script.

Here are my email settings:

I enabled debug mode and the error_log says the email was sent, but it was never received.

I ensured the emails were being sent to a valid Kanboard user.

I checked my Apache error logs and got no email related errors.

any ideas?

Hi Lara, welcome to the forum.

From the PHP docs:

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

Maybe you could give more details about your installation.

So after a lot of testing, I discovered that PHP mail fails when there is an invalid email address in the headers. Since I am using PHP 8, and the PHP constant PHP_EOL has changed between php 7.4. and php 8.x., I followed the advice here and it worked!

2 Likes

May I ask what version of Kanboard you have installed, Miss Lara? Because the version of Kanboard I have installed is 1.2.41, and I encountered the same issue as you when using SMTP to send emails.

You can find the details here:

I am using version 1.2.40

Hi, Lara. I receive the similar problem like you. But I’m using smtp to send email. And I’m using kanboard-1.2.43 and php 8.x. Here is my mail configuration.

define('MAIL_FROM', 'ANY_EMAIL@163.com');

// E-mail address used for the "Bcc" header to send a copy of all notifications
define('MAIL_BCC', '');
// Mail transport available: "smtp", "sendmail", "mail" (PHP mail function)
define('MAIL_TRANSPORT', 'smtp');

// SMTP configuration to use when the "smtp" transport is chosen
define('MAIL_SMTP_HOSTNAME', 'smtp.163.com');
define('MAIL_SMTP_PORT', 587);
define('MAIL_SMTP_USERNAME', 'ANY_EMAIL@163.com');
define('MAIL_SMTP_PASSWORD', 'ANY_PASSWORD');
define('MAIL_SMTP_HELO_NAME', null);
define('MAIL_SMTP_ENCRYPTION','tls');

// Sendmail command to use when the transport is "sendmail"
define('MAIL_SENDMAIL_COMMAND', '/usr/sbin/sendmail -bs');

Do you know how should I change to successfully receive the email sended? I sincerely hope you can give me some advice. TKS.

Did you try this fix: the PHP constant PHP_EOL has changed between php 7.4. and php 8.x.

kanboard-1.2.23/libs/swiftmailer/classes/Swift/Transport/MailTransport.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

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 {
It worked for me.

I read this over and over again, but this in IMHO simply wrong, unless you changed the platform.
On a Linux system, PHP_EOL was and still is 0a.

$ php -r "echo PHP_EOL;" | hexdump -C
00000000  0a 

Or do I miss something?

Yeah, I have read the post about this fix but I am using SMTP. It seems that the fix in line 162~168 is for not using SMTP( also comment in line 163).

163 // Non-windows (not using SMTP)

I’m not sure if this fix works for me. But I will try this after this reply.

Hi, now I have tried this fix but it still does not work. I tried to send a invitation for a new user by a valid email and Kanboard have messaged that it has been successfully sent. However, there’s no response. :smiling_face_with_tear:

图片

Hi, @Lora. I just changed the port from 587 to 465 and the MAIL_SMTP_ENCRYPTION from tls to ssl. Then it works unexpectedly. I never think about its solution could be so simple. :melting_face:
Thank you all for your kind reply.

Correct, it’s the wrong file. According to the file’s comment header:

  • MailTransport.php → mail
  • EsmtpTransport.php → SMTP