0

I'm having some problems with a php mail function I'm trying to implement..

Originally my code was inserting the variables into a database on submit but now I'm trying to swap the code so it gets emailed instead..

The code is as follows.. It doesn't seem to want to work though, any suggestions will be a great help!

Thanks

This is the email function

$email = "[email protected]"
mail($email, $msg, "From: xxxxx \nX-Mailer:PHP/" . phpversion());
header("Location: index.php?act=topic&id=".$advert_id);

and this is the form its just submitted from

echo "<form method=\"post\" action=\"./index.php?act=reply&id=".$row['id']."\">";
echo "<tr><td><textarea style=\"width:90%\" name=\"reply\"></textarea><br><input type=\"submit\" name=\"submit\" value=\"Send Message\" style=\"width:90%\"></td></tr>";
echo "</table>";
4
  • By not work I'm assuming you mean that it's not throwing an error and it's just not sending the email. Are you using WAMP/MAMP? Commented Apr 21, 2011 at 22:37
  • First thing I would do if it's just the mail not going through is check to make sure port 25 (SMTP) is open on your server... but some details as to the OS and the actual problems you're having would definitely help... Commented Apr 21, 2011 at 22:39
  • It's hosted on the internet so I'm not using WAMP/MAMP; regards to it not working, it doesn't throw any errors it just doesn't send email either.. I'll have a look into port 25 and get back to you; cheers! Commented Apr 21, 2011 at 22:50
  • Is this PHP on Windows or Linux? Commented Apr 21, 2011 at 22:52

2 Answers 2

1

You're missing a ; at the end of $email = "[email protected]"

You also haven't declared $msg, but perhaps you've done so elsewhere.

Sign up to request clarification or add additional context in comments.

3 Comments

the semi colon isn't missing in the real script, I accidentally deleted it when I was deleting my email to post but thanks. $msg is defined earlier on, its the content they enter
just checking. Have you ran phpinfo() to insure your PHP mail function is up and running on the server?
I've never really used phpinfo before, I've just run it though, what am I looking for mail wise?
0

If this is PHP running on Windows then you might be encountering this problem:

php mail() function and IIS

2 Comments

In terms of my local machine I'm running Mac OSX - but since I'm not running locally that won't affect it. The server is running Linux..
@sean - no problem, it was just a thought.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.