maxime1992
maxime1992

Reputation: 23813

PHP email : Weird chars

I'm looking for a nice way to send mails on my site.

I've been struggling for hours now, because i randomly get chars in my mails and sometimes it breaks the HTML.

I'm using codeigniter (V3.0) but it was the same deal when i was in 2.x.

Here's the most important part of my code :

$configs = array(
    'protocol'  =>  'smtp',
    'smtp_host' =>  'smtp.my_server.fr',
    'smtp_user' =>  'contact@my_server.fr',
    'smtp_pass' =>  'my_pass',
    'smtp_port' =>  'my_port',
    'mailtype'  =>  'html',
    '_bit_depths' => 'base64',
    '_encoding' =>  'base64'
);

$this->CI->load->library("email", $configs);
$this->CI->email->set_newline("\r\n");
$this->CI->email->to($mail);
$this->CI->email->from("contact@my_server.fr", "My server");
$this->CI->email->subject( $objet );
$this->CI->email->message( $mail_html)) );
$this->CI->email->send();

I just don't get it ... I'm pretty sure, if i was able to send mail in base_64 it would be okay but i'm missing something !

If someone have any idea about that, i would really appreciate.

Thanks in advance.

Upvotes: 2

Views: 83

Answers (1)

maxime1992
maxime1992

Reputation: 23813

If you have the same problem, i found an amazing php library on GitHub. This saved my day : https://github.com/PHPMailer/PHPMailer

Really simple to use and mails are well encoded ...

Hope this help some day,

cheers

Upvotes: 1

Related Questions