music_fan01 Posted August 30, 2011 Share Posted August 30, 2011 I have a client who would like an email contact form on their page, but where I am hosting their website, they do not allow the phpmail () (and they are running php 5). I've asked around in several places and some people have told me to use a phpmailer or a phpmailer class along with an account such as Gmail that allows SMTP (which the client does have an account on Gmail also). Below is my original code that I coded, but wont run on the host where I have the website on (which is Mezoka). I've read some examples and about both the phpmailer and the phomailer class, but its a little confusing to me. Any help is greatly appreciated. code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Contact</title> </head> <body> <?php $to = "starr@yahoo.com"; $body = $_POST["message"]; $headers = "From: user@domain.com\n"; mail($to,$body,$headers); echo "Mail sent to $to"; ?> </body> </html>[/code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="templatemo_wrapper"> <div id="templatemo_header"> <ul id="social_box"> <li><a href="http://www.facebook.com/"><img src="images/facebook.png" alt="facebook" /></a></li> <li><a href="http://www.twitter.com/"><img src="images/twitter.png" alt="twitter" /></a></li> </ul> <div id="site_title"> <h1><a href="index.htm"><img src="images/logo2.png" alt="logo" /><span></span></a></h1> </div> <!-- end of site_title --> </div> <!-- end of templatemo_header --> <div id="templatemo_menu"> <div class="home"><a href="index.htm"></a></div> <ul> <li><a href="index.htm"><span>Home</span></a></li> <li><a href="test.htm"><span>Test</span></a></li> <li><a href="examples.htm"><span>Examples</span></a></li> <li><a href="question.htm"><span>Questions</span></a></li> <li><a href="contact.htm"><span>Contact</span></a></li> <li><a href="comments.htm">Have A Comment?<span>Comments</span></a></li> </ul> </div> <!-- end of templatemo_menu --> <div id="templatemo_content_wrapper"> <div id="templatemo_content_top"></div> <div id="templatemo_content"> <h2>Contact</h2> <div class="cleaner_h50"></div> <div id="contact_form"> <h4>Quick Contact</h4> <form method="post" name="contact" action="email.php"> <div class="col_w340 float_l"> <label for="namer">Name:</label> <input name="name" type="text" class="input_field" id="author" maxlength="40" /> <div class="cleaner_h10"></div> <label for="email">Email:</label> <input name="email" type="text" class="input_field" id="email" maxlength="40" /> <div class="cleaner_h10"></div> </div> <div class="col_w340 float_r"> <label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea> <div class="cleaner_h10"></div> <input type="submit" class="submit_btn float_l" name="submit" id="submit" value="Send" /> <input type="reset" class="submit_btn float_r" name="reset" id="reset" value="Reset" /> </div> </form> </div> <div class="cleaner"></div> </div> <div id="templatemo_content_bottom"></div> </div> <div id="templatemo_sp_box"> <div class="col_w340 float_l"> </div> </div> <div class="col_w340 float_r"> </div> </div> </div> <div id="templatemo_footer"> Copyright © 2011 <a href="www.twitter.com/">Starr</a><br/> <a href="http://www.iwebsitetemplate.com" target="_parent">Website Templates</a> by <a href="http://www.templatemo.com" target="_parent">Free CSS Templates</a> </div> <!-- end of templatemo_footer --> </div> <!-- end of templatemo_wrapper --> </body> </html> Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 30, 2011 Share Posted August 30, 2011 $to = "email address"; $from = " <no-reply@sitename.info >"; $headers = "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.= "From: $from\r\n"; $mail_body = "Hello World"; if (mail($to,"Mail", $mail_body,$headers)) { echo " Thankyou! - Your feedback has been sent! "; } else { echo " Thankyou! - We could not send email. Please try later! "; } ?> [url]http://php.net/manual/en/function.mail.php[/url] Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 30, 2011 Author Share Posted August 30, 2011 So, in the to section I would just add the clients email address and from just the way it is correct? And using that php script will work fine with my form? Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 30, 2011 Share Posted August 30, 2011 $to = " clients email address"; Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 30, 2011 Author Share Posted August 30, 2011 And does the mail_body have to have the 'Hello World'? or can it be empty? Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 30, 2011 Share Posted August 30, 2011 mail_body messages of the mail. Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 30, 2011 Author Share Posted August 30, 2011 So, hello world, wont show up when someone sends a message? And the php will work with the clients gmail address? Because I put my address in and I got an error message to try again sending my message later. Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 30, 2011 Share Posted August 30, 2011 A subject like the headline Email body - The main part of an email message containing the actual, arbitrary data such as text or images. As opposed to the header, which contains control and meta-information gmail - this code will work. Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 30, 2011 Author Share Posted August 30, 2011 Thanks! Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 31, 2011 Author Share Posted August 31, 2011 A subject like the headline Email body - The main part of an email message containing the actual, arbitrary data such as text or images. As opposed to the header, which contains control and meta-information gmail - this code will work. Tested it with Gmail and it does not work. Not too sure if I didnt call something right in my html or if its where I am hosting my site (its mezoka, they allow php 5, but not phpmail () ). Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 31, 2011 Share Posted August 31, 2011 http://www.w3schools.com/php/php_mail.asp Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 31, 2011 Share Posted August 31, 2011 http://www.phpbuilder.com/board/showthread.php?t=10307560 Quote Link to comment Share on other sites More sharing options...
Dusaro Posted August 31, 2011 Share Posted August 31, 2011 yes, I have set this up before and gmail never received the email... I just changed to hotmail. Quote Link to comment Share on other sites More sharing options...
voip03 Posted August 31, 2011 Share Posted August 31, 2011 hotmail is working? ( $to='Hotmail address' , run the code ) Quote Link to comment Share on other sites More sharing options...
music_fan01 Posted August 31, 2011 Author Share Posted August 31, 2011 Any php mail form that might work with gmail? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.