Jump to content

Email


Caligo
 Share

Recommended Posts

I just grabbed the form from the tutorials. I tested it out, changed the email to what mine would be, but it doesn't actually submit. Could someone explain to me how to get it to work? I understand the what each part does for the most part, but don't know how to get it to actually send the email.Below is the original from the tutorial.

<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $email = $_REQUEST['email'];   $subject = $_REQUEST['subject'];  $message = $_REQUEST['message'];  mail( "someone@example.com", "Subject: $subject",  $message, "From: $email" );  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  echo "<form method='post' action='mailform.php'>  Email: <input name='email' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='15' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?>

Link to comment
Share on other sites

it should send...can you post your modified code
the only thing that I changed was what email it was sent to.ill give you my code for the whole page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><link rel="stylesheet" type="text/css" href="css/style.css" /><link rel="shortcut icon" href="images/icon.ico" type="image/x-icon" /><title>lucidSTYLE</title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /></head><body><div class="center">	<div class="header">		<a href="index.html">||<span>HOME</span>|||||||||||</a>|||||<br />		<a href="about.html">||<span>ABOUT ME</span>||||</a>||<br />		<a href="portfolio.html">||<span>PORTFOLIO</span>||</a>||||<br />		<a href="contact.html">||<span>CONTACT</span>|||||</a><span>|||||||||||</span><span>  Contact information</span>		<br />	</div>		<div class="container">				<div class="right_head">		</div>				<div class="background">				<div class="content_a">		<h1>//contact</h1>				<?php			if (isset($_REQUEST['email']))			//if "email" is filled out, send email 			{ 			//send email 			$email = $_REQUEST['email'];  			$subject = $_REQUEST['subject']; 			$message = $_REQUEST['message']; 			mail( "info@lucidstyle.net", "Subject: $subject", 			$message, "From: $email" );			}			else			//if "email" is not filled out, display the form 			{ 			echo "<form method='post' action=''>			  Email: <br /><input name='email' type='text' /><br /><br />			  Subject: <br /><input name='subject' type='text' /><br /><br />			  Message:<br />			  <textarea name='message'>			  </textarea><br /><br />			  <input type='submit' value="Send " />			  </form>";			  }		?>				<br /><br />				<h5>*all fields must be filled to send</h5>				</form>				</div>				</div>			</div>		<div class="footer">				<div class="left">		 Copyright © 2006 Andrew Terpening  		</div>				<div class="right">		  check the site validation: <a title="xhtml" href="http://validator.w3.org/check?uri=referer">xhtml</a> <a title="css" href="http://jigsaw.w3.org/css-validator/validator-uri.html">css</a> 		</div>			 </div>	</div></body></html>

Link to comment
Share on other sites

I do not know much about PHP mail() but in ASP.Net if you do not specify what SMTP server to use then it looks to the server (the PC you are running hte code on) for the STMP settings. If these are not setup on your PC that could be why they are not sending. Just a guess. Is there a way to specify the SMTP server with mail()?EDIT: I found this

In the section entitled [mail function] in the php.ini file, you'll find three settings: SMTP, sendmail_from, and sendmail_path. If your server runs on a Windows machine, you'll want to set the SMTP option to point to your SMTP server (or your ISP's SMTP server, if you're setting up PHP on your home machine).
Link to comment
Share on other sites

I do not know much about PHP mail() but in ASP.Net if you do not specify what SMTP server to use then it looks to the server (the PC you are running hte code on) for the STMP settings. If these are not setup on your PC that could be why they are not sending. Just a guess. Is there a way to specify the SMTP server with mail()?EDIT: I found this
Thanks for the help. I still am not too sure what to do yet, but I'm going to keep looking and trying. I want to learn PHP anyways, why not learn some now right? :)
Link to comment
Share on other sites

i don't know much about this stuff. i am not following where the ini file is...i've never done anything like this before. I am just getting used to xhtml and css. i did very little php a while back, it was basically the "hello world" thing and some form thing, but nothing to send, just posting.

Link to comment
Share on other sites

do you have php installed on your PC or do you use a host? If it is on your pc then it is in the PHP folder you installed, most likely C:\php\php.iniIf you are using a host you will have to ask them about those settings.

Link to comment
Share on other sites

do you have php installed on your PC or do you use a host? If it is on your pc then it is in the PHP folder you installed, most likely C:\php\php.iniIf you are using a host you will have to ask them about those settings.
Oh, I see. I'd have to ask the host. Alright, thanks for the help.
Link to comment
Share on other sites

Oh, I see. I'd have to ask the host. Alright, thanks for the help.
I cant really see any way around this without mailto. You could use these codes:
<FORM METHOD=POST ACTION="mailto:your email?subject=???" ENCTYPE="text/plain">

...and this code

<INPUT TYPE="submit" VALUE="Submit Post" onclick="window.location='thankyou.html';">

If you add your email in the bit that says your email, insert your subject, then you can create a rule in your inbox to send all emails with that subject to a certain folder. Then finally set the page you want to send you viewer to, after they have submitted the form.Insert the first code as the start of your form, and the second one just before you put you reset button in.Hope this has helped youNote you need to leave the ? after your email address if you want a subject

Link to comment
Share on other sites

I was having the same problem with the mail() function.Basically I asked the host why it wasnt working, and they sent me to a page that showed a special library? i think that they had installed on the server. And I had to use that for it to work properly. Its called phpmailer. What host are you using?

Link to comment
Share on other sites

<FORM METHOD=POST ACTION="mailto:your email?subject=???" ENCTYPE="text/plain">

That's a terrible way to do it, you are relying on the fact that the user has an email client installed on their machine and an account set up. The best way to send email from a website is to use a server-side language to do it.
Link to comment
Share on other sites

That's a terrible way to do it, you are relying on the fact that the user has an email client installed on their machine and an account set up. The best way to send email from a website is to use a server-side language to do it.
I know, because, like you say, I am relying on them to have an email, and if you look at the second code, it sends a thankyou page when they click submit, even if I havent recieved an email, but I can use any siver side scripts myself, as I am currently using btconnect to host, and the package I am using is free.I have to pay if I want to be able to use server side scripts!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...