php - 如何通过 CodeIgniter 以联系方式成功发送电子邮件?

标签 php codeigniter email contact-form

我已经设置了我的 Controller 和我的联系表。但是当我在我的联系页面上点击“提交”时,我没有收到任何错误,但我没有收到电子邮件。谁能帮我弄清楚为什么我实际上没有收到电子邮件?我感谢任何帮助。这是我的 Controller 代码:

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

class Home extends CI_Controller {
    public function index()
    {
        $this->template->build('home');
    }

    public function email() {
        $name = $this->input->post('name');
        $email = $this->input->post('email');
        $phone_number = $this->input->post('phone_number');
        $message = $this->input->post('message');
        $this->load->library('email');
        $this->email->from($email, 'Your Name');
        $this->email->to('anish@develop.io');
        $this->email->cc('another@another-example.com');
        $this->email->bcc('them@their-example.com');
        $this->email->subject('Email Test');
        $this->email->message(
          'My name is'.$name.', Im testing this email class. My email is '.$email. '. My Phone number is '.$phone_number.
         ' This is my message '.$message. ' Thanks!!'
         );
        $this->email->send();
        echo $this->email->print_debugger();
        $this->template->build('home');
    }
}

这是我的联系人页面 View 代码:

<div class="inner-content" id="contact-content">

  <title>CSS3 Contact Form</title>
  <div id="contact">
    <h1>Send an email</h1>
    <form method="post" action="/home/email">
      <fieldset>
        <label for="name">Name:</label>
        <input name="name" id="name" type="text" placeholder="Enter your full name">
        <label for="email">Email:</label>
        <input name="email" id="email" type="email" placeholder="Enter your email address">
        <label for="message">Message:</label>
        <textarea name="message" id="message" placeholder="Type your message here..."></textarea>
        <input type="submit" value="Send message">
      </fieldset>
    </form>
  </div>
</div>

最佳答案

php.ini 文件中启用 php_openssl.dll 并尝试使用 gmail。 Pascal Spruit 或 Omade 的答案将起作用。在 php.ini 文件中编辑后不要忘记重启本地服务器。

关于php - 如何通过 CodeIgniter 以联系方式成功发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16969572/

相关文章:

php - elasticsearch 版本 1.2.1 的脚本错误

php - ubuntu 升级后 mcrypt_create_iv 不再在 apache2 上工作

php - 使用 codeigniter 3 和 dynamodb 进行查询

html - 电子邮件模板管理器工具

node.js - 带有 sendmail 插件的 Nodemailer 不起作用

php - 除最后一行外的中心 float

php - 用数组填充对象的属性?

php - 如何将图片存入数据库

mysql - 如何在codeigniter中的sql查询中按姓名搜索最新工作的人?

php - "Unable to open primary script:/usr/share/webapps/roundcubemail/webmail/index.php (No such file or directory)"