Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

fEmail $headers bug?

posted by lutsen 7 years ago

When using the fEmail class to send e-mails, certain from and to e-mail address combinations produce an error. It seems to have something to do with the $headers variable in the mail() function. When I remove this variable in line 1467, the error is gone.

From the few different addresses I have tested, the error occurs with a combination of a to- and from e-mail address that both share our own domain (hoverkraft.nl), and a combination of hoverkraft.nl and gmail.com.

Any ideas on what causes this?

Oh, and by the way: I think Flourish is great!

@lutsen

What is the error it produces? Do you have an example of the code which you are using leading up to this?

posted by mattsah 7 years ago

Sorry for my slow repy.

This is the error: Fatal error: Uncaught exception 'fConnectivityException' with message 'An error occured while trying to send the email entitled TEST' in /test_bless/flourish/fEmail.php:1478 Stack trace:

  1. 0 /www/test_bless/test.php(16): fEmail->send()
  2. 1 {main} thrown in /test_bless/flourish/fEmail.php on line 1478

This is the code:

$email = new fEmail();
$email->addRecipient('xxx@hoverkraft.nl');
$email->setFromEmail('xxx@hoverkraft.nl');
$email->setSubject('TEST');
$email->setBody('TEST');
$email->send();

As I said: the error occurs with a combination of a to- and from e-mail address that both share our own domain (hoverkraft.nl), and a combination of hoverkraft.nl and gmail.com. Other addresses do work. It seems to have something to do with the $headers variable in the mail() function. When I remove this variable in line 1467 in fEmail.php, the error is gone.

posted by lutsen 7 years ago

@lutsen are there any strange characters in the from e-mails? I understand you don't want to show the e-mails here, but this is the only thing you're indicating is differing. Given that it's using the system's mail command my guess is it's not properly escaping one of the e-mails when it passes the arguments.

posted by mattsah 7 years ago

No, no strange characters, just replace the xxx with lutsen. But as I said, if I remove the $headers variable in the mail() in line 1467 of the fEmail class, it does work. So I guess it has something to do with the headers...

posted by lutsen 7 years ago

var_dump the $headers variable at that point and paste it here?

posted by mattsah 7 years ago

It seems sometimes the Message-ID is not set. At first I thought this caused the error, but it happens with working- and non-working e-mail addresses. And the non-working are never sent, and the working are allways sent, eventhough they also sometimes seem to have no Message-ID.

string(169) "From: xxx@hoverkraft.nl Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable"

string(169) "From: xxx@hoverkraft.nl Message-ID: <1e7f078b44.1341347820@> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable" 
posted by lutsen 7 years ago