Reputation: 405
Since the update from PHP 7.4 to 8.1 I get strange messages by sending emails.
$config = Array(
'protocol' => 'asmtp',
'smtp_host' => 'asmtp.mail.*****.com',
'smtp_port' => 587,
'smtp_user' => '[email protected]',
'smtp_pass' => '*******',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$message = $this->load->view('email/index.php', $data, TRUE);
$subject = "My title;
$this->load->library('email', $config);
$this->email->set_mailtype("html");
$this->email->set_crlf( "\r\n" );
$this->email->from('[email protected]');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($message);
$this->email->attach($root.'assets/'.$attachment);
Error message:
This is a multi-part message in MIME format. Your email application may not support this format.
--B_ATC_64eceaf56642a Content-Type: multipart/alternative; boundary="B_ALT_64eceaf566426"
--B_ALT_64eceaf566426 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
--B_ALT_64eceaf566426 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I changed the charset from UTF-8 to ISO-8859-1 and some others but this doesn't solve the problem. Additionally, there was no change on the mailserver.
Upvotes: 2
Views: 455
Reputation: 921
I upgraded my PHP from version 7.4 to 8.2 yesterday, and just noticed that mails were no longer being sent correctly, in a way that matches the original poster's issue in PHP 8.1.
In my case, the cause seems to be that, since that upgrade, the CodeIgniter 3 Email library seems to use only "\n" as line separator in the header of outgoing e-mails. By changing this to "\r\n", the issue was resolved.
I achieved this by changing the application/config/email.php
file to contain the following line:
$config['newline'] = "\r\n";
Presumably you can also achieve the same result by setting the newline whenever you call the library:
$this->email->set_newline("\r\n");
Upvotes: 0