【发布时间】:2013-06-02 21:40:25
【问题描述】:
我已经设置了我的控制器和我的联系表格。但是当我在我的联系页面上单击“提交”时,我没有收到任何错误,但我没有收到电子邮件。谁能帮我弄清楚为什么我实际上没有收到电子邮件?我很感激任何帮助。这是我的控制器代码:
<?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');
}
}
这是我的联系人页面视图代码:
<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>
【问题讨论】:
-
首先请确保您已设置 smtp 服务器以正确发送电子邮件。
-
调试器回显了什么?
-
输出是这样的:您的消息已使用以下协议成功发送:mail From: "Your Name" Return-Path: Cc: another@another-example.com Bcc: them@their -example.com 回复:“dfgrfgh@gd.com” X-Sender:dfgrfgh@gd.com X-Mailer:CodeIgniter X-Priority:3(正常) Message-ID: Mime-版本:1.0 内容类型:文本/纯文本; charset=utf-8 Content-Transfer-Encoding: 8bit =?utf-8?Q?Email_Test?= 我的名字是dfdfdf,我正在测试这个电子邮件类。我的电子邮件是 dfgrfgh@gd.com。我的电话号码是这是我的消息 dfdfdfdfdfsdafsafsdfsfdsfdsfsdf 谢谢!!
标签: php codeigniter email contact-form