Contact form for WordPress website without additional plugins

There are different plugins that enable contact form for WordPress websites. For some reason none of them worked correctly on my blog. Knowing some basic WordPress and php basics I thought that I could do without a plugin. I bring to your attention a page template for sending mail:

* Template Name: Contact Form
  if( ($_POST['frommail'] != '') && ($_POST['subject'] != '') && ($_POST['msg'] != '') && ($_POST['fromname'] != '') ){
  	$to = "<strong>[email protected]</strong>";
  	$subjectfrom = $_POST['fromname'];
  	$subjectdata = $_POST['subject'];
  	$subject = "[Contact form reply] " . $subjectdata;
  	$msg = $_POST['msg'];
  	$from = $_POST['frommail'];
  	$msg .= " \r\n";
  	$msg .= "\r\n От $subjectfrom";
  	$headers = "From: $from";

		echo '<center><b>The message has been sent.</b><br><br>';

<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">

<center><table style="width:40%;">
<tr> <td>E-mail address *:</td><td><input type="text" name="frommail" /></td></tr>
<tr><td>Your Name *:</td><td><input type="text" name="fromname" /></td></tr>
<tr><td>Subject *:</td><td><input type="text" name="subject" /></td></tr>
<tr><td>ВашеYour message *:</td><td><textarea rows="4" cols="23" name="msg"></textarea></td></tr>
<tr><td colspan="2"> <input type="submit" value="Send" /></td></tr>

<?php get_footer(); ?>

It has to be saved into the %theme_folder%/page-templates/contact-form.php.

Дальше заходим в админку, создаем еще одну страницу. Название выберите на Ваше усмотрение. Прокручиваем страницу вниз в правой части экрана в разделе Атрибуты страницы выбираем шаблон Contact Form. Сохраняем. Радуемся.

Next go to the admin panel and create new page. Scroll down the page on the right side of the screen in the Page Attributes section, select the Contact Form template. Hit save.

Screenshot from 2014-03-12 03:11:18

Don’t forget to change [email protected] to your email address.

Result looks like the following: Screenshot from 2014-07-11 16:07:28