I have the code below which works for me on my test server, but not in "Azure App services" because it doesn't have its own "SMTP server".
Are there some simple way to make the code work or do I need to change it entirely?
I have SMTP server, which I can use, but I really don't know how.
I know practically nothing about php and azure servers.
<?php
mb_internal_encoding("UTF-8");
//index.php
$error = '';
$name = '';
$email = '';
$surname = '';
$phone = '';
$secretKey = 'Hehe';
$captcha = $_POST['g-recaptcha-response'];
function clean_text($string)
{
$string = trim($string);
$string = stripslashes($string);
$string = htmlspecialchars($string);
return $string;
}
if(isset($_POST["submit"]))
{
if(empty($_POST["name"]))
{
$error .= '<p><label class="text-danger">Vložte své jméno prosím.
</label></p>';
}
else
{
$name = clean_text($_POST["name"]);
}
if(empty($_POST["email"]))
{
$error .= '<p><label class="text-danger">Zadejte svůj email prosím.</label></p>';
}
else
{
$email = clean_text($_POST["email"]);
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$error .= '<p><label class="text-danger">Nesprávný formát emailu.</label></p>';
}
}
if(empty($_POST["surname"]))
{
$error .= '<p><label class="text-danger">Zadejte prosím své
příjmení.</label></p>';
}
else
{
$surname = clean_text($_POST["surname"]);
}
if(empty($_POST["phone"]))
{
$error .= '<p><label class="text-danger">Zadejte prosím své
telefonní číslo.</label></p>';
}
else
{
$phone = clean_text($_POST["phone"]);
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if($error == '' && intval($responseKeys["success"]) == 1)
{
$file_open = fopen("pxJTVuaPrxbo4KJKawLI/contact_data.csv", "a");
$no_rows = count(file("pxJTVuaPrxbo4KJKawLI/contact_data.csv"));
if($no_rows > 1)
{
$no_rows = ($no_rows - 1) + 1;
}
$form_data = array(
'sr_no' => $no_rows,
'name' => $name,
'surname' => $surname,
'email' => $email,
'phone' => $phone
);
$recipients = array(
"info@optimal-energy.cz",
"matej.konecny@getmore.cz",
);
$EmailTo = implode(',', $recipients); // your email address
$EmailFrom = $email;
$Subject = "Kariérní stránka OE - Nový zájemce o pozici";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "From: info@getmore.cz\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '<html><body>';
$message .= '<p style="color:#080;font-size:18px;">Z kariérního webu Optimal Energy přišel nový kontakt!</p>';
$message .= '<b>Jméno:</b> '.$name;
$message .= '<br><b>Příjmení:</b> '.$surname;
$message .= '<br><b>Email:</b> '.$email;
$message .= '<br><b>Telefonní číslo: </b> '.$phone;
$message .= '</body></html>';
mail($EmailTo, $Subject, $message, $headers);
fputcsv($file_open, $form_data);
fclose($file_open);
$error = '<div class="text-center"><label class="text-success">Děkujeme za Váš zájem. V blízké době Vás budeme kontaktovat.</label><div>';
$name = '';
$surname = '';
$email = '';
$phone = '';
}
else
{
$error .= '<p><label class="text-danger">Opravdu nejste robot?</label></p>';
}
}
?>
Thanks for the help in advance.