PHP: how to send email basics

前端 未结 7 1180
滥情空心
滥情空心 2021-01-28 18:05

I\'m would like to use PHP to send email from my localhost to other people. What do I need to do that?

For example do I need to install mailserver? If I\'m not mistaken

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 18:36

    There is no need for an installation of a special module to have access to mail functions in PHP. But For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following:

    /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. 
    

    It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.

    If you are working on a linux environment using a hosting provider is most likely that the sendmail is already present, otherwise you can check from a terminal doing:

    cat some_file.txt |mail -s "test mail" user@yourmail.com
    

提交回复
热议问题