Mesaj de Eroare la Transmiterea unui email

Secţiune dedicată începatorilor.

Moderatori: Moderatori, Start Moderator

tengelmann
PHPRomania Supporter
Mesaje: 16
Membru din: Mar Iul 13, 2010 11:02 am

Mesaj de Eroare la Transmiterea unui email

Mesajde tengelmann » Joi Sep 29, 2011 9:14 am

Buna Dimineata,

Incerc sa transmit un email dintr-un formular, cu urmatorul cod:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php // GDMR form processor

$nume = $_POST['nume'];
$firma = $_POST['firma'];
$adresa = $_POST['adresa'];
$telefon = $_POST['telefon'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$dataceruta = $_POST['dataceruta'];
$observatii = $_POST['observatii'];

// format text
$message = 'Comanda produse de pe gdmr.ro';
$message .= '<br><br>Produs: Linie de alimentare carcasata';
$message .= '<br><br>Nume si prenume: ' . $nume;
$message .= '<br><br>Firma: ' . $firma;
$message .= '<br><br>Adresa: ' . $adresa;
$message .= '<br><br>Telefon: ' . $telefon;
$message .= '<br><br>Fax: ' . $fax;

$message .= '<br><br>E-mail: <a href="mailto:' . $email . '">' . $email .'</a>';
$message .= '<br><br><br>Data ceruta: ' . $dataceruta;
$message .= '<br><br>Observatii: ' . $observatii;
$message .= '<br><br>';

//************** [ Run ] *****************

$to = 'zoltan@gdmr.ro';

$subject = 'Comanda componente linie de alimentare carcasata';

$body = $message;

$from = $email;
$reply_to = $email;

$headers = "MIME-Version: 1.0\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-2\r\n";

$headers .= "From:" . $from . "\r\n";

$headers .= "Reply-to: " . $reply_to ;
//*********************************************

if (mail( $to, $subject, $body, $headers ) == true)
{
header('Location: confirmare.html');
} else {

echo 'Mesajul dumneavoastra nu a putut fi trimis';
exit();
}

?>
</head>
<body>
<br>
</body>
</html>

Dar primesc urmatorul mesaj de eroare:
WARNING: bad headers - Improper use of control character (char 0D hex):
MIME-Version: 1.0\r\n Improper use of control character (char 0D hex):
Content-type: text/html; charset=iso-8859-2\r\n Improper use of control
character (char 0D hex): From:x@x.ro\r\n

Am incercat de toate, dar nu gasesc sursa erorii, codul pare in regula.

Va rog sa ma ajutati, multumesc.

Cu stima,
Zoltán



Avatar utilizator
teachme
Senior Member
Mesaje: 550
Membru din: Mar Aug 17, 2010 11:52 am

Mesajde teachme » Joi Sep 29, 2011 9:23 am

Scoate "\r" lasa doar "\n" vezi daca face la fel.

tengelmann
PHPRomania Supporter
Mesaje: 16
Membru din: Mar Iul 13, 2010 11:02 am

Mesajde tengelmann » Joi Sep 29, 2011 10:52 am

Excelent, mersi, a functionat sfatul, acum codul nu mai da eroare.
Ciudat este ca am preluat \r\n dintr-o carte de PHP, de aceea nu inteleg de ce nu este OK. In fine...

O zi buna,
Z.


Înapoi la “PHP Incepători”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 20 vizitatori