I solve the banal task - sending mail using php.

The form processing code is:

if((isset($_POST['username'])&& $_POST['username']!='')&& (isset($_POST['email'])&& $_POST['email']!='')) { //Проверка отправилось ли наше поля name и не пустые ли они $to = 'recepient@example.com'; //Почта получателя, через запятую можно указать сколько угодно адресов $subject = 'Заявка с сайта example.com'; $message = ' <html> <head> <title>'.$subject.'</title> </head> <body> <p>Имя заказчика: '.$_POST['username'].'</p> <p>Его телефон: '.$_POST['email'].'</p> <p>Обращение было сделано с сайта example.com</p> </body> </html>'; $headers = "Content-type: text/html; charset=utf-8; \r\n"; //Кодировка письма $headers.= "From: Birthday Reminder <birthday@example.com>\r\n"; $headers.= "Bcc: birthday-archive@example.com\r\n"; mail($to, $subject, $message, $headers); //Отправка письма с помощью функции mail print_r($_POST); print($headers); } 

The POST output gives the following result:

Array ([email] => int@mail.ru [username] => Andrey25)
Content-type: text / html; charset = utf-8;
From: Birthday Reminder
Bcc: birthday-archive@example.com

As if everything is there except the mailbox itself, which I simply display on the screen. Explain to me, what is this for such "wonders" of technology here?

    2 answers 2

    Try this:

     $email = explode('@', $_POST['email']); $message = '... <p>Его телефон: '.$email[0].'@'.$email[1].'</p> ...'; 

      You do not see the mailbox because you see the result in the browser. and the browser takes it as an HTML tag and does not display it. View the source of the page and see the full output.

      In my projects I used SwiftMailer http://swiftmailer.org/ . Mail site hung on google mail, connected and sent all the letters from it. It is possible that the letters are being sent, only now in the mail services there is some kind of verification for the authenticity of the domain, or somehow, that the letters from the local domains are not sent or accepted. Try to connect to the existing mailbox and send from it using SwiftMailer

      • It would be nice, but sending a letter didn't roll either ... Delays in mail, or something else. And without frames, too, does not display the way for me. So it's not about tags. - IntegralAL
      • In my projects I used SwiftMailer swiftmailer.org . Mail site hung on google mail, connected and sent all the letters from it. It is possible that the letters are being sent, only now in the mail services there is some kind of verification for the authenticity of the domain, or somehow, that the letters from the local domains are not sent or accepted. Try to connect to the existing mailbox and send it from it using SwiftMailer - s4urp8n