dongyue934001 2016-07-26 06:59
浏览 44
已采纳

使用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>

And this is my controller

  <?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();
    }


 }
}

I don't have any error.

  • 写回答

1条回答 默认 最新

  • dourao1877 2016-07-26 09:06
    关注

    Try the below code.

    $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'   => "
    "
                 );
                    $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();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)