Codeigniter - 面向发送电子邮件和用户电子邮件输入的问题

时间:2014-01-19 09:42:05

标签: php forms codeigniter email

我做简单表格用户提交电子邮件和城市提交表格并发送电子邮件给godaddy的感谢我主人网站的用户,当我提交它显示错误。 1-发送电子邮件错误 2- $电子邮件输入没有得到 建议我分享代码。

user.php控制器

public function sendUserMail($email) {
   $this->load->library('email');
   $email = $this->input->get("email");   
   $this->email->from('noreply@abc.com', 'Halalat');
   $this->email->to('$email'); 
   $this->email->subject('Halalat Newsletter Subscription');
   $this->email->message('Testing');   
   //$this->email->attach('/assests/images/photo1.jpg');
   $this->email->send();
   echo $this->email->print_debugger();
  } 

在配置文件夹中我制作email.php

<?php

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'host.abc.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'noreply@abc.com';
$config['smtp_pass'] = 'abc';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";

?> 

模型中的user_model.php

function create_member()
 {
   $new_member_insert_data = array(
    'email' => $this->input->post('email'),
    'city' => $this->input->post('city'),       
   );
   $insert = $this->db->insert('users', $new_member_insert_data); 
  return $insert;


 } //create_member 

1 个答案:

答案 0 :(得分:0)

试试这个,

   $this->load->library('email');
   $config['protocol'] = 'smtp';
   $config['smtp_host'] = 'ssl://host.abc.com';
   $config['smtp_port'] = '465';
   $config['smtp_user'] = 'noreply@abc.com';
   $config['smtp_pass'] = 'abc';
   $config['charset'] = 'utf-8';
   $config['mailtype'] = 'html';
   $config['wordwrap'] = TRUE;
   $this->email->initialize($config);
   $email = $this->input->get("email");   
   $this->email->from('noreply@abc.com', 'Halalat');
   $this->email->to('$email'); 
   $this->email->subject('Halalat Newsletter Subscription');
   $this->email->message('Testing');   
   if(!$this->email->send()){
     echo $this->email->print_debugger();
   }