Mail () in PHP is always unsuccessful. & Lt ;? Php $ to & nbsp; = & nbsp; "757006080@qq.com"; $ subject & nbsp; = & nbsp; "Test & nbsp; mail"; $ message & nbsp; = & nbsp; "He PHP always fails to send emails via mail.
$to = "757006080@qq.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "757006080@qq.com";
$headers = "From: $from";
$send=mail($to,$subject,$message,$headers);
if($send)
echo "Mail Sent";
else
echo "Sorry,mail sent failed!"
?>
Wamp used in the development environment, download and install the sendmail program, and change php. ini and sendmail. ini according to the Internet.
Foxmail 7.1 is used to create an account for your QQ mailbox and the POP3/SMTP service is enabled. Change the sending server to POP3 and use the same authentication as the receiving server. The result still reports the following Error: Warning: mail (): SMTP server response: 503 Error: need EHLO and AUTH first! In F: \ PHP \ wamp \ www \ mail. php on line 8
I don't know where it is wrong. please kindly advise. Thank you !!!
Mail () sendmail QQ mail shared:
------ Solution --------------------
You can try phpmailer.
$ Path = realpath (dirname (_ FILE _). '/../libraries/Mail. php ';
Include ("$ path ");;
$ Mail = new Mail (); // create a new object
$ Mail-> IsSMTP (); // you can specify the SMTP mode to send messages.
$ Mail-> SMTPAuth = true; // you need a license to set SMTP.
$ Mail-> SMTPSecure = "ssl"; // The SMTP host of Gmail needs to use SSL secure authentication
$ Mail-> Host = "smtp.gmail.com"; // SMTP Host of Gamil
$ Mail-> Port = 465; // The SMTP Port of the SMTP master machine of Gamil is Port 465.
$ Mail-> CharSet = "UTF-8"; // you can specify a portable component.
$ Mail-> Username = "onlyfortestlzz@gmail.com"; // Set your certificate
$ Mail-> Password = "abcde"; // you can specify the secret of your certificate.
$ Mail-> From = "onlyfortestlzz@gmail.com"; // Set the sender's mailbox
$ Mail-> FromName = "staff member"; // Set the sender's name
$ Mail-> Subject = "PHPMailer Courier letter"; // Set the Subject matter
$ Mail-> Body = "Hello ";
// Set the content of the firmware.
$ Mail-> IsHTML (true); // set the content of the email to HTML.
$ Mail-> AddAddress ($ this-> input-> post ('backemail'), $ value-> username); // specify the receiver and its name.
If (! $ Mail-> Send ()){
Echo 'OK ';
}