-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
When sending an email only containing ASCII:
require_once("./class.simple_mail.php");
$from = 'me@somewhere.org';
$email = new SimpleMail();
$email->setFrom($from, 'Me')
->setParameters('-f'.$from)
->setReplyTo($from, '')
->setTo('...@yahoo.com', 'Someone')
->setTo('...@gmail.com', 'Another one')
->setSubject('Subject')
->setMessage('Check your email.');
$email->send();
I got the following error in my e-mail Inbox:
host mailfilter.hostnet.nl[91.184.19.251] said: 550
Subject contains invalid characters. (in reply to end of DATA command)
So I changed the encodeUtf8Word() to:
/**
* encodeUtf8Word
*
* @param string $value The word to encode.
*
* @return string
*/
public function encodeUtf8Word($value)
{
$isAscii = true;
for ($i=0; $i<strlen($value); $i++) {
$ch = ord(substr($value, $i, 1));
if ($ch >= 128) {
$isAscii = false;
break;
}
}
if ($isAscii) {
return $value;
} else {
return sprintf('=?UTF-8?B?%s?=', base64_encode($value));
}
}
After this change, the email sends correctly, no error anymore.
So encodeUt8Word() should prefer plain ASCII, without encoding.
Metadata
Metadata
Assignees
Labels
No labels