Hi guys,
I’m trying to send email to clients with this php script using my hostmonster server.
But it doesn’t send the email and it shows no errors so I don’t know what the problem is. I’m guessing it has to do with the SMTP that has to be authenticated but I have no idea how to do that (tried to for 5 hours now).
If the solution is too complicated, could you guide me on any other way I can send emails to clients using php (maybe without SMTP)?
<?php
if ($_POST['submit'])
{
//get data from form
$name = $_POST['name'];
$message = $_POST['message'];
if ($name&&$message)
{
$namelen=20;
$messagelen=300;
if (strlen($name)<=$namelen&&strlen($message)<=$messagelen)
{
//everything is ok
//set smpt in php.ini
ini_set("SMTP", "mail.ciudadanossinfronteras.com");
//setup variables
$to = "adamschroeder@asia.com";
$subject = "email from adam";
$headers = "From: admin@ciudadanossinfronteras.com";
$body = "This is an email from $name\
\
$message";
mail($to, $subject, $body, $headers);
die();
}
else
die("Max length for name is $namelen and max length for message is $messagelen");
}
else
die("you must enter name and message");
}
?>
<html>
<form action='sendmeanemail.php' method='POST'>
Name:<input type='text' name='name'><br>
Message<textarea name='message'></textarea><p>
<input type='submit' name='submit' value='Send me this'>
</html>