0

i have code for send email to my email

but if i press ok i get can not send email to **@hotmail.com

i work on linux server (fedora), and i don not change any settings

my mail.html file is

<html>
<head><title>Mail sender</title></head>
<body>
<form action="mail.php" method="POST">
<b>Email</b><br>
<input type="text" name="email" size=40>
<p><b>Subject</b><br>
<input type="text" name="subject" size=40>
<p><b>Message</b><br>
<textarea cols=40 rows=10 name="message"></textarea>
<p><input type="submit" value=" Send ">
</form>
</body>
</html>

and my email.php file is :

<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php

# Retrieve the form data
$email      = $_POST['email'];
$subject    = $_POST['subject'];
$message = $_POST['message'];

# Sends mail and report success or failure
if (mail($email,$subject,$message)) {
  echo "<h4>Thank you for sending email</h4>";
} else {
  echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>

please try help me

1 Answers1

0

Best if you use a dedicated script for sending emails. Such as PHPMailer which gives you various config options including SMTP:

// Send Mail
$mail = new PHPMailer(); // initiate
$mail->IsSMTP(); // use SMTP

// SMTP Configuration
$mail->SMTPAuth = true; // set SMTP
$mail->Host = "myhost"; // SMTP server
$mail->Username = "email@email.com";
$mail->Password = "password";            
$mail->Port = 465; // change port is required
malta
  • 858
  • 1
  • 9
  • 17
  • how can i get username & password for smtp – user3264926 Feb 10 '14 at 11:43
  • This is from your server. If you are sending the email from an SMTP server then these would be the username and password of that email account. You may also opt not to use SMTP. Have a look at the PHPMailer examples and see which one is best for you - http://phpmailer.worxware.com/index.php?pg=examples – malta Feb 10 '14 at 12:23