Код формы отправки сообщений:
<html>
<head>
<title>Форма контактной информации</title>
</head>
<body>
<h1>Форма контактной информации</h1>
<form method="post" action="handler.php">
<p>Субъект:<br /><input type="text" name="subject" /></p>
<p>Сообщение:<br /><textarea name="message"></textarea></p>
<input type="submit">
</form>
</body>
</html>
Код handler.php:
<html>
<head>
<title>Функции</title>
</head>
<body>
<?php
// Получатель (измените на ваш e-mail адрес)
$strEmail = "x@mail.ru";
// Получить пользовательские вводы
$strSubject = $_POST["subject"];
$strMessage = $_POST["message"];
mail($strEmail,$strSubject,$strMessage);
echo "Mail Sent.";
?>
</body>
</html>
при нажатии на "Отправить" выдаdfkjcm следующее:
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in D:\usr\mosts\localhost\www\Mail.php on line 17
Погуглил и изменил handler.php на:
ini_set('SMTP', "localhost");
ini_set('smtp_port', "25");
ini_set('sendmail_from', "x@mail.ru");
$to = 'xx@mail.ru';
$strSubject = $_POST["subject"];
$strMessage = $_POST["message"];
$headers = 'From: x@mail.ru' . "\r\n";
mail($to, $subject, $message, $headers);
теперь выдает Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\usr\mosts\localhost\www\Mail.php on line 19
В ini следующее:
[mail function]
For Win32 only.
http://php.net/smtp
SMTP = localhost
http://php.net/smtp-port
smtp_port = 25
For Win32 only.
http://php.net/sendmail-from
sendmail_from = x@mail.ru
Таки как слать себе сообщения?)