adding SSL to php contact form

the mail() function

Moderators: egami, macek, gesf

Post Reply
hoster21
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Jan 22, 2018 4:06 am

Mon Jan 22, 2018 4:12 am

Hi all,

I have recently added SSL to my website and since then my contact form is not working. I contacting the admin who told me that I need to configure the form using the mail settings below however I am unsure how were to add them to my form. Any help would be appreciated.

Outgoing mail server: uk41.siteground.eu
Outgoing port: 465

Code: Select all

<?php 
$errors = '';
$myemail = 'info@example.com';

  if(empty($_POST['name'])  || 
           empty($_POST['email']) || 
           empty($_POST['message'])) {
        $errors = 'Please enter all required fields';
    }
    else
    {
     $name = $_POST['name']; 
     $email = $_POST['email']; 
     $message = $_POST['message'];
   } 

if( empty($errors))
{
	$to = $myemail; 
	$email_subject = "Website Query: $name";
	$email_body = "You have received a new message. ".
	" Here are the details:\n Name: $name \n Email: $email \n Message \n $message"; 
	
	$headers = "From: $myemail\n"; 
	$headers .= "Reply-To: $email";
	
	mail($to,$email_subject,$email_body,$headers);
	//redirect to the 'thank you' page
	header('Location: thanks.html');
} 
?>

Post Reply