电子邮件正在本地发送,但在网站上传时会出错 这里是图书馆的代码请帮忙
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Emaillib {
function send_email($fromEmail, $fromName, $details) {
$CI = & get_instance();
$CI->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'abc@gmail.com'; // Email
$config['smtp_pass'] = '*****'; // Password
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$CI->email->initialize($config);
$CI->email->from($fromEmail, $fromName);
$CI->email->to('abc@xyz.com'); // To Email
$CI->email->reply_to($fromEmail, $fromName);
$CI->email->subject('Enquiry through Website');
$CI->email->message($details);
$isSent = $CI->email->send();
//echo $CI->email->print_debugger();
if (!$isSent) {
return 'false';
}
return 'success';
}
}
&GT;
答案 0 :(得分:0)
因为你说它在本地工作正常,它表明它是代码的问题,而是服务器配置。很难说确切的问题是什么,但我会做以下
extension=php_openssl.dll
尝试开始并看看会发生什么