我目前正在构建一个在线注册系统,其中一个模块是注册系统。
用户注册成功后,会向其邮箱地址发送一封验证邮件。我遵循了我在网上阅读的每个教程,但我仍然遇到同样的问题。
这是我到目前为止得到的:
//this is what it looks like in my controller after validation of fields from registration
$this->load->library('email');
$this->email->set_newline("\r\n");
$this->email->from('my_personal_email@gmail.com', 'Mike Lee');
$this->email->to($email);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if($this->email->send()){
//this is to check if email is sent
redirect('site/registered');
}else{
//else error
show_error($this->email->print_debugger());
}
对于我的 email.php 配置:
class CI_Email {
var $useragent = "CodeIgniter";
var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
var $protocol = "smtp"; // mail/sendmail/smtp
var $smtp_host = "https://smtp.googlemail.com"; // SMTP Server. Example: mail.earthlink.net
var $smtp_user = "my_personal_email@gmail.com"; // SMTP Username
var $smtp_pass = "my_personal_emailpassword"; // SMTP Password
var $smtp_port = "25"; // SMTP Port
var $smtp_timeout = 10; // SMTP Timeout in seconds
var $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off
var $wrapchars = "76"; // Number of characters to wrap at.
var $mailtype = "text"; // text/html Defines email formatting
var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
var $alt_message = ''; // Alternative message for HTML emails
var $validate = FALSE; // TRUE/FALSE. Enables email validation
var $priority = "3"; // Default priority (1 - 5)
var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
// even on the receiving end think they need to muck with CRLFs, so using "\n", while
// distasteful, is the only thing that seems to work for all environments.
var $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
var $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature
var $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
var $_safe_mode = FALSE;
var $_subject = "";
var $_body = "";
var $_finalbody = "";
var $_alt_boundary = "";
var $_atc_boundary = "";
var $_header_str = "";
var $_smtp_connect = "";
var $_encoding = "8bit";
var $_IP = FALSE;
var $_smtp_auth = FALSE;
var $_replyto_flag = FALSE;
var $_debug_msg = array();
var $_recipients = array();
var $_cc_array = array();
var $_bcc_array = array();
var $_headers = array();
var $_attach_name = array();
var $_attach_type = array();
var $_attach_disp = array();
var $_protocols = array('mail', 'sendmail', 'smtp');
var $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
var $_bit_depths = array('7bit', '8bit');
var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
这是错误:
/* 遇到 PHP 错误
严重性:警告
消息:fsockopen() [function.fsockopen]:无法连接到 ssl://smtp.googlemail.com:25(连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。)
文件名:库/Email.php
行号:1689 */
我使用我的个人电子邮件帐户发送测试邮件。但我不知道这是否适用于gmail。您能以某种方式启发我如何测试我的代码是否正常工作吗?或者有没有可以作为我的测试服务器发送邮件的软件?
谢谢。:(