U
U
unib0nger2016-02-23 11:31:16
PHP
unib0nger, 2016-02-23 11:31:16

How to put the user's email instead of the hoster in the incoming letter?

How to make me see not the hosting technical email, with the receipt of the letter, but the user who indicated his email in the form on the site?
38ac363f2760.png
What is it for: to send an auto-reply to the user, they say follow the link, there you will download the file.
Or how to make it so that when sending a user's email from a form on the site, a letter was sent to him - follow the link, there you will download the
html file

<form action= "post2.php" method= "POST">
<p> <input type= "text" name= "email"></p>
<input type= "submit" value= "Отправить"></form>

<?
// ----------------------------конфигурация-------------------------- //
$adminemail="[email protected]";  // e-mail админа
$date=date("d.m.y"); // число.месяц.год
$time=date("H:i"); // часы:минуты:секунды
$backurl="http://site/2/site/send.htm";  // На какую страничку переходит после отправки письма
//---------------------------------------------------------------------- //

// Принимаем данные с формы
$name=$_POST['name'];
$email=$_POST['email'];
$msg=$_POST['message'];

// Проверяем валидность e-mail
if (!preg_match("|^([a-z0-9_\.\-]{1,20})@([a-z0-9\.\-]{1,20})\.([a-z]{2,4})|is",
strtolower($email)))
{
  echo
"<center>Вернитесь <a
href='javascript:history.back(1)'><B>назад</B></a>. Вы
указали неверные данные!";
  }
else
{
$msg="
<p>E-mail: $email</p>

";

// Отправляем письмо админу
mail("$adminemail", "$date $time $name", "$msg");

// Сохраняем в базу данных
$f = fopen("message.txt", "a+");
fwrite($f," \n $date $time Сообщение от $name");
fwrite($f,"\n $msg ");

fclose($f);

// Выводим сообщение пользователю
print "<script language='Javascript'><!--
function reload() {location = \"$backurl\"}; setTimeout('reload()', 6000);
//--></script>
$msg
<p>Доступ придёт вам на почту в течение 5 минут.</p>";
exit;
}
?>

PS. All the guys from February 23!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-02-23
@unib0nger

$header = "MIME-Version: 1.0\nContent-type: text/html; charset=windows-1251\nFrom: {$email}\n"";
mail("$adminemail", "$date $time $name", "$msg", $header);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question