无法在CodeIgniter中发送电子邮件

奇奇·里兹基(Kiki Rizki)

我正在创建一个页面以发送电子邮件并将其存储到数据库中。我已经尝试过并设法保存到数据库中,但是无法发送到电子邮件。

我的控制器

public function create() 
    {
        $data = array(
        'email' => $this->input->post('email',TRUE),
        'requestorname' => $this->input->post('requestorname',TRUE),
        'namemess' => $this->input->post('namemess',TRUE),
        'nomess' => $this->input->post('nomess',TRUE),
        );
    $this->load->model('mymodel');
    $this->mymodel->insert($data);
    $this->load->library('email');
    $config = array();
    $config['charset'] = 'iso-8859-1';
    $config['useragent'] = 'Codeigniter';
    $config['protocol']= "smtp";
    $config['mailtype']= "html";
    $config['smtp_host']= "sxxxxx.gridserver.com";
    $config['smtp_port']= "465";
    $config['smtp_user']= "[email protected]";
    $config['smtp_pass']= "mypass"; 
    $config['newline']="\r\n"; 
    $config['wordwrap'] = TRUE;

    $this->email->initialize($config);
    $subject = "Confirmation";
    $this->email->from($config['smtp_user']);
    $this->email->to('email'); 
    $this->email->subject($subject);
    $this->email->message('.$data['requestorname'].','.$data['namemess'].','.$data['nomess'].');
    $this->email->send();
    echo $this->email->print_debugger();
            redirect(site_url('page'));
        }
    }

和我的模特

public $table = 'mydatabase';
    public $id = 'id';
    public $order = 'DESC';

  // insert data
    function insert($data)
    {
        $this->db->insert($this->table, $data);
    }

怎么解决呢?

菲利普斯·西兰(Philipus Silaen)

试试我从一些免费教程中获得的代码

$config = Array(   
        'protocol' => 'smtp',
        'mailpath' =>'/usr/sbin/sendmail',
        'smtp_host' => 'sxxxxx.gridserver.com',
        'smtp_port' => 25,
        'smtp_timeout' =>7,
        'smtp_user' => '[email protected]', // change it to yours
        'smtp_pass' => '******', // change it to yours
        'mailtype' => 'html',
        'charset' => 'utf-8',
        'crlf' => "\r\n",
        'newline' => "\r\n",
        'wordwrap' => TRUE
    );

   $this->email->initialize($config);
    $this->email->from('[email protected]'); 
    $this->email->to($data['email']);


    $this->email->subject($subject); #change
    $this->email->message($message); #change
    if($this->email->send())
    {

        echo "mail send";
    }
    else
    {
        show_error($this->email->print_debugger());

    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在 Codeigniter 2 中发送电子邮件时出错

来自分类Dev

无法在Django Rest框架中发送电子邮件

来自分类Dev

无法使用 nodemailer 在 nodejs 中发送电子邮件

来自分类Dev

无法在hostgator中发送电子邮件

来自分类Dev

在MVC中发送电子邮件

来自分类Dev

在R中发送电子邮件

来自分类Dev

无法在Codeigniter中正确发送电子邮件

来自分类Dev

为什么在CodeIgniter中无法发送电子邮件?

来自分类Dev

无法使用CodeIgniter的电子邮件库发送电子邮件

来自分类Dev

在Codeigniter中发送电子邮件时出现错误500

来自分类Dev

JavaMail无法发送电子邮件

来自分类Dev

Gitlab无法发送电子邮件

来自分类Dev

无法从PHP发送电子邮件

来自分类Dev

Gitlab无法发送电子邮件

来自分类Dev

Poco无法发送电子邮件

来自分类Dev

Django无法发送电子邮件

来自分类Dev

无法在ASP.NET MVC中发送电子邮件

来自分类Dev

在GO中发送电子邮件,无法设置Return-Path标头

来自分类Dev

无法使用Gmail SMTP在Spring Boot中发送电子邮件

来自分类Dev

Yii2无法在yii2中发送电子邮件

来自分类Dev

无法通过smtpmail + starttls在emacs中发送电子邮件

来自分类Dev

无法在 cron 运行的管理命令中发送电子邮件

来自分类Dev

如何使用Mailgun在Swift中发送电子邮件

来自分类Dev

ActionMailer不在本地环境中发送电子邮件

来自分类Dev

如何使用Spree在开发中发送电子邮件

来自分类Dev

在Android App背景中发送电子邮件

来自分类Dev

通过Outlook在R中发送电子邮件

来自分类Dev

在Sharepoint Online 2013中发送电子邮件

来自分类Dev

在表单提交中发送电子邮件