Why does the linux-SMTP server reject emails sent by the PHP function?

Source: Internet
Author: User
{Code...} log on to the server using mail-s & quot; test & quot; ***** @ qq.com to test whether the smtp server can send emails. Why is the function written in PHP rejected? This function used to work and has never been moved. {Code ...}
SMTP server error: 5.7.1 <********@qq.com>: Relay access denied

Log on to the server and use mail-s "test" ***** @ qq.com to test whether the smtp server can send emails. Why is the function written in PHP rejected? This function used to work and has never been moved.

Public function SendMail ($ address, $ title, $ message) {vendor ('phpmailer. class # phpmailer '); $ mail = new PHPMailer (); // Set PHPMailer to use the SMTP server to send an Email $ mail-> IsSMTP (); // set HTML $ mail-> ishtml (true); // sets the character encoding of the email. If this parameter is not specified, it is 'utf-8' $ mail-> CharSet = 'utf-8'; // add the recipient address, you can use it multiple times to add multiple recipients $ mail-> AddAddress ($ address); // Set the email Body $ mail-> Body = $ message; // Set the From Field of the mail header. $ Mail-> From = C ('mail _ address'); // Set the SENDER name $ MAIL-> FromName = C ('mail _ sender '); // Set the mail title $ mail-> Subject = $ title; // Set the SMTP server. $ Mail-> Host = C ('mail _ SMTP '); // Set it to "verify" $ MAIL-> SMTPAuth = true; // Set the user name and password. $ Mail-> Username = C ('mail _ loginname'); $ MAIL-> Password = C ('mail _ password'); // send an email. $ Mail-> Send (); return $ mail ;}

Reply content:
SMTP server error: 5.7.1 <********@qq.com>: Relay access denied

Log on to the server and use mail-s "test" ***** @ qq.com to test whether the smtp server can send emails. Why is the function written in PHP rejected? This function used to work and has never been moved.

Public function SendMail ($ address, $ title, $ message) {vendor ('phpmailer. class # phpmailer '); $ mail = new PHPMailer (); // Set PHPMailer to use the SMTP server to send an Email $ mail-> IsSMTP (); // set HTML $ mail-> ishtml (true); // sets the character encoding of the email. If this parameter is not specified, it is 'utf-8' $ mail-> CharSet = 'utf-8'; // add the recipient address, you can use it multiple times to add multiple recipients $ mail-> AddAddress ($ address); // Set the email Body $ mail-> Body = $ message; // Set the From Field of the mail header. $ Mail-> From = C ('mail _ address'); // Set the SENDER name $ MAIL-> FromName = C ('mail _ sender '); // Set the mail title $ mail-> Subject = $ title; // Set the SMTP server. $ Mail-> Host = C ('mail _ SMTP '); // Set it to "verify" $ MAIL-> SMTPAuth = true; // Set the user name and password. $ Mail-> Username = C ('mail _ loginname'); $ MAIL-> Password = C ('mail _ password'); // send an email. $ Mail-> Send (); return $ mail ;}

PHPMailer uses functions that are frequently disabled by the ISP, such as popen. you can use phpinfo () to query the value of disable_functions to see if function is disabled.

Thanks for your answers. Finally, the error is found because/var/run/saslauthd is changed to 710 after sasl is restarted. Therefore, chmod is required.

I use the thinkphp framework. can I solve this problem?

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.