Email Sending from Local Server in PHP

后端 未结 2 546
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 13:27

I have my file mail.php :






        
相关标签:
2条回答
  • 2020-12-21 14:03

    You need to set up your SMTP server in your php.ini.

    The directives you need to change are listed here. The settings should be provided by your hosting provider.

    But before we get ahead of ourselves, just a quick warning:

    • You are sending the email by masquerading as someone else by setting the Email in the "from" header.

    • Most SMTP server would require some form of authentication, for example to send something using the gmail SMTP server, I would need to authenticate with my username and password.

    • If the email in the form field does not match the authentication username, it could be rejected by the server, or it could be changed to reflect the authentication username. Finally, it might not play well with spam filters.

    My suggestion is that you send the email from one of your own email accounts, for example (customerenquiry@yourdomain.com). Then in the body of the message, put in the customer's email address. You can also set the reply-to header to the customer's email address, so that clicking "reply to" in your email client would automatically put their email address in the "to" field.

    0 讨论(0)
  • 2020-12-21 14:24

    Try this:

    1. Open the php.ini.

    2. Search for the attribute called SMTP in the php.ini file. Generally you can find the line SMTP=localhost. change the localhost to the smtp server name of your ISP. And the set the port of 25.

      SMTP = smtp.gmail.com #user your smtp address here
      smtp_port = 25
      
    3. Restart the apache server or wamp or xammp. Whatever you are using.

    4. Now try to send the mail using the mail() function

    0 讨论(0)
提交回复
热议问题