[英]Sending an email via localhost in PHP
我正在尝试通过PHP发送电子邮件。 它给出以下警告。
Warning: mail() [function.mail]: Failed to connect to mailserver at
"smtp.ntlworld.com" port 25, verify your "SMTP" and "smtp_port" setting in
php.ini or use ini_set() in C:\wamp\www\wagafashion\customerside\BulkInquiry.php
on line 1007
在php.ini中, SMTP已作如下更改。
[mail function]
; For Win32 only.
SMTP = smtp.ntlworld.com
smtp_port = 25
; For Win32 only.
sendmail_from = tiny1999@gmail.com
配置php.ini之后,WAMP重新启动,并给出了以上警告。 要通过PHP的本地主机发送电子邮件还有哪些其他设置?
改用PHPMailer: https : //github.com/PHPMailer/PHPMailer
如何使用它:
require('./PHPMailer/class.phpmailer.php');
$mail=new PHPMailer();
$mail->CharSet = 'UTF-8';
$body = 'This is the message';
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Username = 'me.sender@gmail.com';
$mail->Password = '123!@#';
$mail->SetFrom('me.sender@gmail.com', $name);
$mail->AddReplyTo('no-reply@mycomp.com','no-reply');
$mail->Subject = 'subject';
$mail->MsgHTML($body);
$mail->AddAddress('abc1@gmail.com', 'title1');
$mail->AddAddress('abc2@gmail.com', 'title2'); /* ... */
$mail->AddAttachment($fileName);
$mail->send();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.