在codeigniter中的电子邮件概念

时间:2018-05-17 06:05:10

标签: php email-integration

我是初学者需要向填写注册表的所有人发送email verification link。但我得到这样的错误: 无法使用PHP mail()发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。

Date: Thu, 17 May 2018 11:29:31 +0530
From: "Mydomain" <kumarinfo89@gmail.com>
Return-Path: <kumarinfo89@gmail.com>
Reply-To: <kumarinfo89@gmail.com>
User-Agent: CodeIgniter
X-Sender: kumarinfo89@gmail.com
X-Mailer: CodeIgniter
X-Priority: 5 (Lowest)
Message-ID: <5afd1a436d57c@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

在上面我收到了相同的发件人电子邮件,回复你可以看到上面的内容。我尝试更改"\n" into "\r\n"并尝试将587更改为465,以及在dds中更改php.ini。我挣扎了一个多星期的任何帮助

1 个答案:

答案 0 :(得分:0)

configuration

    First of all paste the downloaded condeigniter directory inside server directory(e.g. for XAMPP xampp->htdocs folder)

    config codeigniter database connection in 

codeiniter->application->config->database.php

/ *本地服务器* /

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'company',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

在公司数据库中创建Employee表。

CREATE TABLE IF NOT EXISTS `employee` (
  `emp_id` int(11) NOT NULL AUTO_INCREMENT,
  `emp_name` varchar(200) NOT NULL,
  `address` varchar(250) NOT NULL,
  `email` varchar(200) NOT NULL,
  `username` varchar(100) NOT NULL,
  `password` varchar(100) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`emp_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

在创建发送电子邮件功能之前,打开php&gt; php.ini文件,找到&#39; extension = php_openssl.dll&#39;然后在行的开头删除分号。完成后重启服务器。

配置电子邮件设置

//config email settings
        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'ssl://smtp.gmail.com';
        $config['smtp_port'] = '465';
        $config['smtp_user'] = $from;
        $config['smtp_pass'] = '******';  //sender's password
        $config['mailtype'] = 'html';
        $config['charset'] = 'iso-8859-1';
        $config['wordwrap'] = 'TRUE';
        $config['newline'] = "\r\n"; 

        $this->load->library('email', $config);
    $this->email->initialize($config);


//send email
        $this->email->from($from);
        $this->email->to($receiver);
        $this->email->subject($subject);
        $this->email->message($message);

        $this->email->send()

https://github.com/kasunbuddhima/codeigniter-signup-form-with-email-verification