change smtp port from 25 to 587?

前端 未结 5 644
不知归路
不知归路 2021-01-12 12:34

My ISP have blocked port 25 for sending mails from PHP, and instead have allowed port 587 or 465 to be used. how do i force php mail function to use port 587 instead of defa

5条回答
  •  孤独总比滥情好
    2021-01-12 13:14

    Set smtp_port = 587 in your php.ini. See http://php.net/manual/en/mail.configuration.php

    EDIT

    As AJ noted, this won't fix the problem if you're using your local postfix or sendmail, which you do by specifying smtp = localhost. Try setting that to your ISP's SMTP server address instead.

    That might lead to the next problem if they also require authentication before allowing you to send mail, which many ISPs do. In that case, your best bet would be the Pear Mail package. That will incidentally also allow you to specify the mail server and port in your script. From the documentation:

    $params["host"] - The server to connect. Default is localhost.
    $params["port"] - The port to connect. Default is 25.
    $params["auth"] - Whether or not to use SMTP authentication. Default is FALSE.
    $params["username"] - The username to use for SMTP authentication.
    $params["password"] - The password to use for SMTP authentication.
    

提交回复
热议问题