hey guys, i have the following code for a contact form, i havnt got access to the php.ini file with my web host so ive had to use headers
<?php
$headers = "From: myemail@email.com\r\n";
$headers .= "Reply-To: myemail@email.com\r\n";
$headers .= "Return-Path: myemail@email.com\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
ini_set ("SMTP","smtp.gmail.com");
ini_set ("sendmail_from","frommail@googlemail.com");
if(isset($_POST['submit'])) {
$to = "me@me.com";
$subject = "Contact from Site";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body, $headers);
}
else {
echo "an error has occurred";
}
?>
<form method="POST" action="contact.php">
<input type="text" name="name">
<br/>
<input type="text" name="email">
<br/>
<textarea rows="9" name="message" cols="30"></textarea>
<br/>
<input type="submit" value="Submit" name="submit">
</form>
as you can see, im trying to make the code send the message through a google acount, but im getting the following error:
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. 10sm872297eyz.39
can anyone please show me how to edit my code so this works
thanks guys