Mail () in PHP is always unsuccessful. -Php Tutorial

Source: Internet
Author: User
Mail () in PHP is always unsuccessful. Mail () sendmail QQ mailbox

 


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 !!!


Reply to discussion (solution)

You can try phpmailer.

$ Path = realpath (dirname (_ FILE __)). '/.. /libraries/Mail. php '; include ("$ path"); $ mail = new Mail (); // create a new object $ mail-> IsSMTP ();//? Always use SMTP to send emails $ mail-> SMTPAuth = true ;//? Required for SMTP ?? $ Mail-> SMTPSecure = "ssl"; // SMTP master of Gmail? Need to use SSL ?? $ Mail-> Host = "smtp.gmail.com"; // SMTP master of Gamil? $ Mail-> Port = 465; // SMTP master of Gamil?? Port 465. $ Mail-> CharSet = "UTF-8 ";//? OK? ?? $ Mail-> Username = "onlyfortestlzz@gmail.com ";//? Yes ???? $ Mail-> Password = "abcde ";//? Yes ?? Password? $ Mail-> From = "onlyfortestlzz@gmail.com ";//? Sender's mailbox $ mail-> FromName = "? ";//? Sender name $ mail-> Subject = "PHPMailer ?? Letter ";//? OK? ?? $ Mail-> Body = "Hello ";//? OK?? Rong $ mail-> IsHTML (true );//? OK?? Rong? HTML $ mail-> AddAddress ($ this-> input-> post ('backemail'), $ value-> username );//? Recipient? Parts and name? If (! $ Mail-> Send () {echo 'OK ';}

We recommend that you use pear to install the following three:
(1), Mail
(2), Net_SMTP
(3), Mail_Mime

The mail () function fails because it does not exist.
$ Mail-> Host = "smtp.gmail.com"; // SMTP master of Gamil?
Is it sent from an account.
The email sent by this function is considered as spam by the receiving server. Note: the spam in the mailbox is not very spam. Here, I threw it away.
Php uses phpmailer, and pear is rarely used.

The mail function can only use self-configured SMTP servers without user authentication.
If your SMTP is not approved by the email Alliance, the sent emails will be processed as spam emails.

You can try phpmailer.

$ Path = realpath (dirname (_ FILE __)). '/.. /libraries/Mail. php '; include ("$ path"); $ mail = new Mail (); // create a new object $ mail-> IsSMTP ();//? Always use SMTP to send emails $ mail-> SMTPAuth = true ;//? Required for SMTP ?? $ Mail-> SMTPSecure = "ssl"; // SMTP master of Gmail? Need to use SSL ?? $ Mail-> Host = "smtp.gmail.com"; // SMTP master of Gamil? $ Mail-> Port = 465; // SMTP master of Gamil?? Port 465. $ Mail-> CharSet = "UTF-8 ";//? OK? ?? $ Mail-> Username = "onlyfortestlzz@gmail.com ";//? Yes ???? $ Mail-> Password = "abcde ";//? Yes ?? Password? $ Mail-> From = "onlyfortestlzz@gmail.com ";//? Sender's mailbox $ mail-> FromName = "? ";//? Sender name $ mail-> Subject = "PHPMailer ?? Letter ";//? OK? ?? $ Mail-> Body = "Hello ";//? OK?? Rong $ mail-> IsHTML (true );//? OK?? Rong? HTML $ mail-> AddAddress ($ this-> input-> post ('backemail'), $ value-> username );//? Recipient? Parts and name? If (! $ Mail-> Send () {echo 'OK ';}
Thank you. PHPMAILER has been used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.