Witam
Przepraszam, jeśli moje pytanie jest dość trywialne jednak mam problem z wysyłaniem maili z formularza PHP.
Strona stoi na hostingu OVH i dla strony stworzylem przykładową skrzynkę Webmail.
Wpisałem nazwę skrzynki webmail do swojego formularza PHP np. [email protected]
Chce aby maile wysyłać na ten adres a one dalej przekierowywane są przez OVH na inne adresy email.
Jeden z adresów email jest na wp.pl i otrzymuje następujący błąd
"550 BLAD SPF - zobacz strone
/ SPF Error: Od nadawcow wymagamy poprawnych wpisow SPF / Senders are
required to provide correct SPF records "
Mój formularz PHP wygląda następująco:
<?php
$name = ($_GET['name']) ? $_GET['name'] : $_POST['name'];
$email = ($_GET['email']) ?$_GET['email'] : $_POST['email'];
$phone = ($_GET['phone']) ?$_GET['phone'] : $_POST['phone'];
$comment = ($_GET['comment']) ?$_GET['comment'] : $_POST['comment'];
//flag to indicate which method it uses. If POST set it to 1
if ($_POST)
$post=1;
//Simple server side validation for POST data, of course, you should validate the email
if (!$name)
$errors[count($errors)] = 'Proszę podać swoje imie i nazwisko.';
if (!$email)
$errors[count($errors)] = 'Proszę podać swój adres email.';
if (!$phone)
$errors[count($errors)] = 'Proszę podać swój telefon.';
if (!$comment)
$errors[count($errors)] = 'Proszę wpisać swoją wiadomość.';
//if the errors array is empty, send the mail
if (!$errors) {
//recipient - replace your email here
$to = '[email protected]';
//sender - from the form
$from = $name . ' <' . $email . '>';
//subject and the html message
$subject = 'Wiadomość z formularza Swierkowy Raj od ' . $name;
$message = '<html><body>';
$message .= '
<table border="1" style="width: 100%; border-spacing: 1px; border-style: solid; border-collapse:collapse;">
<tr>
<th colspan="2" style="height: 50px; padding: 15px;"><H1>Wiadomość z formularza Swierkowy Raj od: ' .$name.'</H1></th>
</tr>
<tr>
<td width="20%" style="height: 50px; padding: 5px;"><b>Imię i Nazwisko klienta: </b></td>
<td width="80%" style="height: 50px; padding: 5px; text-align: justify; text-justify: inter-word;">' . $name . '</td>
</tr>
<tr>
<td width="20%" style="height: 50px; padding: 5px;"><b>Numer telefonu: </b></td>
<td width="80%" style="height: 50px; padding: 5px; text-align: justify; text-justify: inter-word;">' . $phone . '</td>
</tr>
<tr>
<td width="20%" style="height: 50px; padding: 5px;"><b>Adres e-mail: </b></td>
<td width="80%" style="height: 50px; padding: 5px; text-align: justify; text-justify: inter-word;">' . $email . '</td>
</tr>
<tr>
<td width="20%" style="height: 50px; padding: 5px;"><b>Treść wiadomość: </b></td>
<td width="80%" style="height: 50px; padding: 5px; text-align: justify; text-justify: inter-word;">' . nl2br($comment) . '</td>
</tr>
</table>';
$message .= '</body></html>';
//send the mail
$result = sendmail($to, $subject, $message,$from);
//if POST was used, display the message straight away
if ($_POST) {
if ($result)
echo 'Dziękujemy! Odpiszemy najszybciej jak to będzie możliwe.';
else
echo 'Przepraszamy! Coś poszło nie tak. Spróbuj później';
//else if GET was used, return the boolean value so that
//ajax script can react accordingly
//1 means success, 0 means failed
}
else {
echo $result;
}
//if the errors array has values
}
else {
//display the errors message
for ($i=0; $i<count($errors); $i++) echo $errors[$i] . '<br/>';
echo '<a href="index.html">Powrót</a>';
exit;
}
//Simple mail function with HTML header
function sendmail($to, $subject, $message, $headers) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$result = mail($to,$subject,$message,$headers);
if ($result)
return 1;
else
return 0;
}
?>
Wydaje mi się, że robię coś nie tak w funkcji mail. Również dodatkowo jak wyślę wiadomość i dam Reply to nie wybiera mi adresy Reply To.
Bardzo proszę o pomoc