A
A
Alexander2015-06-11 22:28:05
Google
Alexander, 2015-06-11 22:28:05

Why does a Gmail contact form send a file and not a text message?

Actually, there is a question in the topic, I fill out the form, and a file arrives in the mail, in accordance with the type "text / plain" or "text / html", instead of a simple message with data from the form. On mail.ru everything works as it should. What can be wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2015-06-12
@td4k

Show the code, please.
Mb the problem is in the headers??

A
Alexander, 2015-06-12
@td4k

I know that this is a pi ** ets in one word, not a code. I'm not a programmer, I'm just learning to write code.. I will accept all criticism and advice wisely, I will correct myself and my mistakes)

$message = "
    <html>
<body>
<p>Контакты</p>
<table>
 <tr><td>Имя: ".$_POST['name']."</td></tr>
 <tr><td>Номер: ".$_POST['phone']."</td></tr>
 <tr><td>Email: ".$_POST['email']."</td></tr>
</table>
</body>
</html>";
  function mime_header_encode($str, $data_charset, $send_charset) { // функция преобразования заголовков в верную кодировку 
    if($data_charset != $send_charset) {
    $str=iconv($data_charset,$send_charset.'//IGNORE',$str);
    }
    return ('=?'.$send_charset.'?B?'.base64_encode($str).'?=');
  }
  
  $data_charset='UTF-8';
  $send_charset='windows-1251';
  $dc=$data_charset;
  $sc=$send_charset;
  $type='text/html';
  $from_email= '...'; // от кого
  $from_name= '...';
  $to_email= '...'; // кому
  $subject = 'Поступил заказ!';
  $enc_from= mime_header_encode($from_name,$dc,$sc).'<'.$from_email.'>';
  $message = iconv($dc,$sc.'//IGNORE',$message);
  $headers.="Mime-Version: 1.0\r\n";
  $headers.="Content-type:".$type."; charset=".$sc."\r\n";
  $headers.="From: ".$enc_from."\r\n";
  $result = mail($to_email,$subject,$message,$headers);
  if($result){
    header('Refresh: 0; url=...');
    ?>
    <script type='text/javascript'>alert('Спасибо за заказ! Мы Вам перезвоним!')</script>
    <?php
  } else {
    echo 'GET LOST!'; 
  }

V
Vladimir, 2015-06-12
@mvs

Where does the double type in Content-type: text/htmltext/html; come from?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question