Jump to content

simple, but can't figure out whats wrong


acidglitter

Recommended Posts

I'm trying to get a contact page to work, and this is the code I'm using, but its not reaching my email for some reason.. Does anyone see whats wrong with this?

 

$name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comment'];

$to="myemail@hotmail.com";
$subject="NEW message from";
$headers="From: $name";
$now=date("M d, Y");
$message="$comment

----------------------------
From: $name
Sent: $now";
mail($to,$subject,$message,$headers);

Link to comment
Share on other sites

Are you sure your server is set up right? If you are using shared hosting, then you might call your host and ask about sending mail from php. In one instance, I had to use this code to make sending mail possible:

ini_set("SMTP","mail.mysite.com"); // this being my server's SMTP outgoing server
// yours could be smtp.yourdomain.com
ini_set("smtp_port","25"); // you might have a different port number for SMTP

Link to comment
Share on other sites

Two suggestions:

 

#1 - avoid using 'free' email addresses since they routinely dump email with less than perfect and complete headers

 

#2 - check the php manual to see what headers you need to use.  Yours is woefully short of what's needed.

Link to comment
Share on other sites

Try this code

$name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comment'];

 

$to="myemail@hotmail.com";

$subject="NEW message from";

$headers="From: $name";

$now=date("M d, Y");

$message="$comment

 

----------------------------

From: $name

Sent: $now";

$ok=mail($to,$subject,$message,$headers);

if($ok==1)

{

echo"message sucessfully send";

}else{

echo"Error!Try again";

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.