Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

php mailer not working

the mail() function

Moderators: macek, egami, gesf

php mailer not working

Postby gpx » Fri Apr 06, 2012 12:51 pm

I new to php but im trying to learn. Im trying to get the php mailer to work but it gives me this error

"Warning: Cannot modify header information - headers already sent by (output started at /home/content/82/8370882/html/gmg/sendmail.php:2) in /home/content/82/8370882/html/gmg/sendmail.php on line 11"

This is script for form:

<form name="contact" method="post" action="sendmail.php" onsubmit="return Validations();">
<label>Name: (required) </label><input class="input1" id="name" name="name" type="text" value="" />
<label>Email: (required) </label><input class="input1" id="email" name="email" type="text" value="" />
<label>Phone: (required) </label><input class="input1" id="phone" name="phone" type="text" value="" />
<label>Comments: (required) </label><textarea class="input2" name="comments" id="comments" cols="" rows=""></textarea><br />
<input type="image" src="images/submit-button.jpg" alt="" name="submit" value="" />
</form>

and the is mailer script:

<?php
if(isset($_POST['submit'])) {
$msg = 'Name: ' .$_POST['name'] ."\n"
.'Email: ' .$_POST['email'] ."\n"
.'Phone: ' .$_POST['phone'] ."\n"
.'Comments: ' .$_POST['comments'];
mail('johndoe@gmail.com', ' Quote', $msg);
header('location: thank-you.php');
} else {
header('location: contact-us.php');
exit(0);
}
?>

Can anyone help me figure out what wrong?
thanks
gpx
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Apr 06, 2012 12:45 pm

Re: php mailer not working

Postby egami » Mon Apr 09, 2012 4:31 am

try this..

if (mail($email,$subject,$message)) {
do this..
} else {
echo "ERROR! Check your error log file.";
}

// This might be in /var/log/maillog or also in /var/log/http/error_log
// You may also want to turn on HTTP error reporting..


Cya.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron