# My PHP mail script not working???



## Damion

hey guys i have a email script in php and for some reason it will not send. i have tryed righting my own, using tutorials and all kineds of other things. what is wrong with my code?

MY HTML


Code:


<Form method="post" action="sendmail.PHP">
Email: <input name="email" type="text" /> <br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea> <br />
<input type="submit" value="submit"><br />
</form>

MY PHP FILE


Code:


<?
  $email = $_REQUEST['email'];
  $message = $_REQUEST['message'];

   mail( "[email protected]", "Feedback Form Results",
      $message, "From: $email");
     header( "Location: http://americanvideo.mywebcommunity.org/");
?>


----------



## Redcore

Works for me. When I was first testing it...I forgot to remove your email and put mine - so perhaps you see that it worked for me too 

Does it say WHY it's not working? Any Error codes for you?

Is your PHP document truly named "sendmail.PHP" with capital PHP or is it "sendmail.php" ? That would make a difference (not trying to insult your intelligence, but since your code works for me...ya never know!)

Just so you know, you should always strip tags whenever you have people posting anywhere...whether to the database or your email (unless you have a WYSIWYG editor attached and they're SUPPOSED to be adding that stuff - which requires trust by your users).

All you have to do is add this at the very top...it will automatically strip the tags of every posted variable:


PHP:


$_POST = array_map('strip_tags', $_POST);



...btw you might want to remove your email in the post above...so nobody can spam it :F


----------



## Damion

Yah it din't send to me when you did it earlier. I relised that it was XHTML (i had it as just HTML) so i made a new page and did it for XHTML. I am testing it now as the browser i was working on did not support XHTML (i thought browsers that did not support XHTML automaticly just read it as HTML? i know the IE 5 i was using today did not) I am sorry for beeing so n00bish i just started PHP this week I mainly do C#. Net .
So i will try the hole strip tag thing (it din't say anything like that in my PHP for dummies book, what exacly does that do....again sorry for beeing such a n00b here) 

and out of curiosity how long do these forms usualy take to send?

(sorry about the grammer and spelling, can not fined a spell check on here and my spelling is really bad)


(lol the edit button is gone for the first post. thats ok though i only use that email for signing up for stuff its my spam account)


----------



## Damion

turns out you can only edit a message for 30 minutes after post. so anyway:

Edit: the script is not working. maybe it is my host that i am using. I will sign up for a new host now hopefuly i can get it working


----------



## Redcore

I saved the form in HTML ... so that SHOULD be fine. I've never had to use XHTML before, to be honest.

That strip code basically grabs every variable that was posted in the previous page and checks to see if they have any HTML tags/code in them. If they do, it strips all that junk and everything that remains is stored in the same variable (making a real easy process out of it). Think of it as a filter...that's all it is. It'll prevent people from trying to include a bunch of crap like huge images just to mess with you/your email.

The time it takes for the email to get to your inbox varies by your server host and your email host. For me, I go through Hostgator for my hosting and Gmail for my email. It gets to my inbox instantly. We can rule out that stuff is going to your junk because when I sent it, I sent through my Gmail to your Gmail...so that's fine.

Your host might not allow emailing...what host do you go through... mywebcommunity.org? I could give you some space to tinker with if you want. My MSN address is available under my username, so you can get ahold of me through that (preferably) or through Yahoo or AIM. I could help you out with your coding too, if you want. You're doing good for being new...so don't stress!


----------



## Damion

o no thanks that is verry nice of you to offer but i would hate to cause problems. mywebcommunity.org is the sub domain they give you a list to choose from. I am using leadhoster -- http://www.leadhoster.com/members_area.html -- they say they support PHP so that should not be the problem. hmmm you know when i was originaly trying to do a mail form in HTML i tryed going through msn with a CGI (my sister told me about it i din't know what it did.) but when i did it said it no longer supported it, I thought that meant the CGI, could it be posible that the eamil clients will not except emails sent through those type of forms? but then again how would they know? i droped out of my net security class when my mom had some major complictions with a surgery (shes fine now) but from the first class i remember somthing about the mail has to go through all kineds of diffrent things befor making it to your mail host........ so that would make that inposible would it not?


----------



## Redcore

Are you hosting there for free? If so, that's the problem...it doesn't give you SMTP (the protocol that sends emails).

I'm not sure about the MSN/CGI stuff - I'd have to read more about it.


----------



## Damion

yes it is free the one i am doing i thoguht if it supported php it would work see learn somthing new every day <(^_^)> thanks for the help.


Edit: I found this : http://www.hostingzero.com/hosting.php but it looks way to good to be true, what do you think, could it be lagitament?


----------



## Redcore

That's a little bizarre that they have different packages...that are all free. Why bother providing 1 GB free when you're providing 10 GB free...I guess each package would give you different ads? It sounds like the guy who runs it will pick up your index and put ads in. Apparently they use Google AdSense...here are the rules for hosting with them:

http://www.hostingzero.com/forum/showthread.php?t=195

For what you want to do...it seems fine. From what I've read, you can better integrate the ads into your site...so if you build a community and don't want a big banner at the top or anything like that, the guy who runs it will let you put the code in where you want it. As long as there is code for the ads (under his Google account) on your site, you should be fine.


----------



## Damion

Ok thanks in hined site i should have looked for that but when i sall the three diffrent hosting packages all for free there were a bunch of red flags that kined of just shot up in my head.

Edit: hmmm it seems they only allow you to be a member if you already have a verry active website (hence why they can be so kined, they must be geting a bunch from Google) I think I am going to rent some space I have been looking at a lot of host that offer nice simple plans for like $6 a month so I will just pack my lunch instead of going to the beffet after school once a mounth and problem solved, my buddy wanted to pack our lunch and have our study group in the park once a mounth anyway.


----------



## Redcore

That would be the best way to go about things.

I go through hostgator...
http://hostgator.com/shared.shtml

It'd be best go with the "Baby" plan for 10/month - 100 GB / 1,000 GB bandwidth...and it comes with pretty much everything (unlimited databases, unlimited hosted domains, unlimited FTP accoutns) - I use this plan and every site I build I just host it on there and charge the client a small hosting fee...so they pay for my hosting pretty much.


----------



## Damion

Redcore said:


> so they pay for my hosting pretty much.


ray: Lmao that is the best idea i have heard in a while, how much do you usualy charge them?

My mom and dad are letteing me use there credit card to order it! (I don't have a credit card or anyway to buy online stuff) My buddy matt and Szabo will be happy to I will give them some space to tinker with.

~Thanks


----------



## Redcore

It depends how big their site is. A few of them previously hosted for 20-30 bucks/month (for 100 MB or some bs...) so I just charge them $10.

I host quite a few friends for free so they can tinker around and put their websites up...and for clans I know and friends who have clans...and then of course my own projects.


----------



## Damion

well good news i got my email form to work. I love hostgator I had some problems at first but after watching the tutorials i got most of it worked out. 

one last question, is there a way to make it when some one types in the URL my homepage displays? I know i could do a URL redirect but then i could not get to my cpannel is there another way of getting to cpannel?

Edit: looks like a lot of people are testing my code and forgeting to change the email i am geting emails from various people all saying "test"


----------



## Redcore

> one last question, is there a way to make it when some one types in the URL my homepage displays? I know i could do a URL redirect but then i could not get to my cpannel is there another way of getting to cpannel?


I'll have to get you to explain this a little further...what URL are you using for HostGator? The main email you signed up with (or purchased through them) would be the cpanel address.


----------

