Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-02-2009, 08:46 PM   PM User | #1
Gabby7
New Coder

 
Join Date: Jul 2009
Location: USA
Posts: 24
Thanks: 13
Thanked 0 Times in 0 Posts
Gabby7 is an unknown quantity at this point
"Simple Contact Form" PHP not sending email

Hello+
I have attempted to write a simple PHP script to send the contact information to a specific email address. Everything seems to be working fine, except the email is not reaching me. I'm not certain what is going wrong - can anyone help? The PHP code is below:

PHP Code:
<?php

/* subject and email variables */

    
$emailSubject 'Contact From Website!';
    
$webMaster 'nomad654321@earthlink.net';
    
/* gathering data variables */

    
$emailField $_POST['email'];
    
$nameField $_POST['cname'];
    
$phoneField $_POST['phone'];
    
$interestedField $_POST['interested'];
    
$artworkField $_POST['artwork'];
    
$commentsField $_POST['comments'];
    
    
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $cname <br>
Phone Number: $phone <br>
Interested in: $interested <br>
Artwork: $artwork <br>
Comments: $comments <br>
EOD;

    
$headers "From: $email\r\n";
    
$headers .= "Content-type: text/html\r\n";
    
$success mail($webMaster$emailSubject$body$headers);
    
/* results rendered as HTML */

    
$theResults = <<<EOD
<html>
<head>
<title>Photography by Lynn Santus</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
    font-family: "Times New Roman", Times, serif;
    font-size: 18px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #330099;
    text-decoration: none;
    background-image: url(images/greengrunge10.png);
    text-align: center;
}
-->
</style>
</head>

<div>
  <div align="center">
    <p><img src="images/lynnbanner.png" alt="Photography by Lynn Santus" width="801" height="150" border="0" usemap="#Map">
<map name="Map"><area shape="rect" coords="84,3,603,154" href="index.html" alt="Link to Home Page">
</map></p>
    <p>Thank you for your interest! Your email will be answered very soon!</p>
    <p>Click <a href="index.html">here</a> to return to the Home Page. </p>
  </div>
</div>
</body>
</html>
EOD;
echo 
"$theResults";

?>
Thank you for any guidance offered...
Gabby7 is offline   Reply With Quote
Old 09-02-2009, 08:51 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Two things-- Turn on full error reporting:

PHP Code:
error_reporting(E_ALL);
ini_set("display_errors"1); 
And check the success of the mail() function-- you assign the result to variable $success but then you don't check it.

PHP Code:
if (!$success) {
    die(
"error sending email!");

If the mail() function fails check your PHP error log.

If all of that doesn't get you anywhere, tell us what kind of PHP install you are using and dump the contents of your phpinfo() here.
__________________
Fumigator is offline   Reply With Quote
Users who have thanked Fumigator for this post:
Gabby7 (09-02-2009)
Old 09-02-2009, 09:03 PM   PM User | #3
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
I also suggest removing your actual email address from your post or you will soon start to get spammed.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Users who have thanked _Aerospace_Eng_ for this post:
Gabby7 (09-02-2009)
Old 09-02-2009, 09:19 PM   PM User | #4
ajetrumpet
Regular Coder

 
ajetrumpet's Avatar
 
Join Date: Jul 2009
Location: Iowa City, IA
Posts: 398
Thanks: 43
Thanked 5 Times in 5 Posts
ajetrumpet is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
And check the success of the mail() function-- you assign the result to variable $success but then you don't check it.

PHP Code:
if (!$success) {
    die(
"error sending email!");

If the mail() function fails check your PHP error log.
you may also want to use your own logs. i do for my website. when i do batch mailings, i write the results to a log then check it when i'm done to see if anything failed in case i need to resend some. it might be of use to you.
PHP Code:
if (!$success) {
   
$logline "delivery failed...|\r\n"; }
else { 
$logline "delivery successful!|\r\n"; }

$file = @fopen("mylogfile""a");
fputs($file$logline );
fclose($file); 
ajetrumpet is offline   Reply With Quote
Users who have thanked ajetrumpet for this post:
Gabby7 (09-02-2009)
Old 09-02-2009, 10:10 PM   PM User | #5
Gabby7
New Coder

 
Join Date: Jul 2009
Location: USA
Posts: 24
Thanks: 13
Thanked 0 Times in 0 Posts
Gabby7 is an unknown quantity at this point
Thank you, everyone! I will do as you suggest and if it doesn't work, then I will re-post. Thank you.
Gabby7 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:17 AM.


Advertisement
Log in to turn off these ads.