How to make my contact form send me Email

心已入冬 提交于 2019-11-29 17:35:27

Email is not sent by JavaScript code in the client; it is sent from the server. When the user hits submit, and all the client side validations have passed, the form data is POST'ed to the server. The form element's "action" attribute specifies what URL on the server should receive the POST'ed form data; i.e. something like action="send_email.php" or something like that.

How the email is actually generated, on the server is entirely dependent on the server technology in use, e.g. PHP, or JSP, or whatever.

So two things are missing in your code above:

  1. the value for action= in the form, and
  2. the server-side code (PHP file, or whatever) that would receive the data and actually send out an email (corresponding to #1)

And to add to @smendola's answer...

Once you have sorted the server-side email sending you might still not be getting the email you're expecting. Some email hosts (quite a few actually) check the validity of signatures of the sending server. If that fails (i.e. no signature or only self-signed signatures in place) the email host might reject the email as spam.

One way to avoid this is to send the form data via SMTP rather than PHP's native send() function. Easiest solution would be PHPMAILER. For example you could send the stuff via an Gmail account.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!