How to configure PHP to send e-mail?

后端 未结 8 1689
星月不相逢
星月不相逢 2020-12-10 07:12

I need to send mail to the users of my website using php script. I have tried using mail function in php.
My code is as follows:

  $to = \"myweb@gmail.co         


        
8条回答
  •  庸人自扰
    2020-12-10 07:23

    Here's the link that gives me the answer and we use gmail:

    Install the "fake sendmail for windows". If you are not using XAMPP you can download it here: http://glob.com.au/sendmail/sendmail.zip

    Modify the php.ini file to use it (commented out the other lines):

    mail function

    For Win32 only.

    SMTP = smtp.gmail.com
    smtp_port = 25
    For Win32 only.
    sendmail_from = @gmail.com
    

    For Unix only.

    You may supply arguments as well (default: sendmail -t -i).

    sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
    

    (ignore the "Unix only" bit, since we actually are using sendmail)

    You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:

    sendmail

    smtp_server=smtp.gmail.com
    smtp_port=25
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username=
    auth_password=
    force_sender=@gmail.com
    

提交回复
热议问题