Sathya Baman
Sathya Baman

Reputation: 3515

codeigniter email not working properly

I am having the small alignment issue in my email. In my message i am manually adding the <br> tag. its not working.

Code

public function send_contact_email($data){
    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => '[email protected]',
        'smtp_pass' => 'password',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );       
    $this->load->library('email', $config);
    //$this->email->set_newline("\r\n");

    // message
    $message = 'you have recived a mail from a customer<br>
                Customer Name : '.$data['fullname'].
                '<br><br>Customer Email : '.$data['contact_email'].
                '<br>Customer website : '.$data['user_web'].
                '<br>message : '.$data['message'];


    // send mail
    $this->email->from('[email protected]', 'Contact Information');
    $this->email->to('[email protected]', '[email protected]'); 
    $this->email->subject('A message from : '. $data['fullname']);
    $this->email->message($message);  
    $this->email->send();
}

But when i receive the mail it looks like this.

enter image description here

The <br> tag is not adding the new line. can some one help me to fix this.

Upvotes: 0

Views: 302

Answers (1)

Armen
Armen

Reputation: 4202

You are missing set as html param for emailer, you have to set it if you want that <br> and other html tags will be recognized in email clients (yahoo, gmail ...)

$this->email->set_mailtype("html");

Upvotes: 1

Related Questions