使用codeigniter发送简单的电子邮件 [英] send simple email using codeigniter

查看:51
本文介绍了使用codeigniter发送简单的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用codeigniter发送简单的电子邮件,如解释此链接 codeigniter电子邮件类别,但是不起作用。
这是我的表单:

I am trying to send simple email using codeigniter as explain this link codeigniter email class ,but it doesn't work. This is my form :

<form method="post" action="<?php base_url()?>main/send_email">
               <input type="text" placeholder="Name" name="name" class="name">
               <input type="text" placeholder="Surname" name="surname" class="surname">
               <input type="email" placeholder="email" name="email" class="email">
               <textarea placeholder="What's on your mind" name="text" class="text"></textarea>
               <input type="submit" value="SEND" class="send_mail" name="send_mail">
</form>

这是我的控制者

  <?php
    defined('BASEPATH') OR exit('No direct script access allowed');

   class Main extends CI_Controller {
     public function __construct(){
     parent::__construct();
     $this->load->helper("common_helper");

    date_default_timezone_set('Asia/Tbilisi');
 }

public function index()
{

    $this->load->view('pages/main');
}

public function send_email()
{
    $this->load->library("email");
    if($this->input->post("send_mail"))
    {
        $name = $this->input->post("name");
        $surname = $this->input->post("surname");
        $email = $this->input->post("email");
        $text = $this->input->post("text");
         $this->email->from($email, $name);
         $this->email->to('77vanich77@gmail.com');
         $this->email->subject('Email Test');
         $this->email->message('testing email message');

         $this->email->send();
    }


 }
}

我没有任何错误。

推荐答案

尝试以下代码。

$email_config = Array(
             'protocol'  => 'smtp',
             'smtp_host' => 'bh-24.webhostbox.net',
             'smtp_port' => '465',
             'smtp_user' => 'feedback@domain.com',
             'smtp_pass' => '12feedback34',
             'mailtype'  => 'html',
             'starttls'  => true,
             'newline'   => "\r\n"
             );
                $this->load->library('email', $email_config);
                $this->email->from($to, 'FEEDBACK');
                $this->email->to('feedback@domain.com');
                $this->email->subject($sub);
                $this->email->message($msg);
                $this->email->send();

这篇关于使用codeigniter发送简单的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆