我想使用localhost中的mail()函数.我安装了WAMP和Gmail帐户.我知道SMTP的Gmail是smtp.gmail.com,端口是465.我需要在WAMP中配置什么才能使用mail()函数?谢谢
我在数字海洋nginx和php 7上运行codeigniter3.03.当我尝试发送电子邮件时,我收到此错误:
码:
严重性:警告消息:fsockopen():无法连接到ssl://smtp.googlemail.com:465(连接超时)文件名:libraries/Email.php行号:1986
我的电子邮件设置是
$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
//$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'xxxxxx@gmail.com';
$config['smtp_pass'] = 'xxxxxxxxxxxx';
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;
Run Code Online (Sandbox Code Playgroud)
这个版本在php 5.x下的同一配置中运行完美.
在php.ini我有
extension=php_openssl.dll
Run Code Online (Sandbox Code Playgroud)
启用.
我无法得到任何暗示,为什么这不应该在php7中工作.任何人都可以给我一个提示要检查的内容或者这个错误的原因是什么.
可能重复:
PHPMailer遇到问题
有很多类似的问题,但没有一个帮助我.
这是我的脚本,它在phpmailer exmaples中提供:
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets …Run Code Online (Sandbox Code Playgroud)