I'm using codeigniter to send mail. It works fine but having this weird problem. The mail is delivered to the recipient and it shows the subject. But it won't show the message and attachment.
Here is the code. I think it's a silly mistake I just can't detect. Help me!
//configure email settings
$config = array(
'protocol'=>'smtp',
'smtp_host'=> 'ssl://smtp.gmail.com',
'smtp_port'=>'465',
'smtp_user'=>'xxxxxxxxxxxxxxxx',
'smtp_pass'=>'xxxxxxxxxxxxxxxx',
);
$开发者_如何学Pythonthis->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('xxxxx@gmail.com','myname');
$this->email->to($email);
$this->email->subject('Test');
$this->email->message('It works!');
//attach newsletter to email
$path=$this->config->item('server root');
$file=$path . '/codeigniter/attachments/newsletter.txt';
$this->email->attach($file);
if($this->email->send())
{
echo "your email was sent";
}
else
{
show_error($this->email->print_debugger());
}
Try changing set_newline to:
$this->email->set_newline("\n");
I have had similar issues in the past, and this fixed it for me.
精彩评论