Jump to content

some kind of mail() problem


enchance

Recommended Posts

I made an email form "contact.php" which makes use of the code below in a separate php file "mail.php"

but I just can't get it to work. I'm kinda new to php.  ;D

 

<?
//assign the constants
$agiemail = "email@agi.com";
$aginame = "AGI";
$inittxt = "WEB: ";

//get the values
$sender = $_POST['fName'];
$subject = $_POST['fSubject'];
$email = $_POST['fEmail'];
$phone = $_POST['fPhone'];
$msg = $_POST['fMessage'];
$checkbox = $_POST['fCheckbox'];
$date = date("l, F j, Y"); 
$time = date("h:i A"); 

//*****The error must be somewhere in the code below*****
$header =
	"To: " . $aginame . "<" . $agiemail . ">\n" .
	"Subject: " . $inittext . $subject . "\n" .
	"From: " . $sender . "<" . $email . ">\n" .
	"X-Mailer: PHP 4.x";

$message = 
	"\n**This message was sent from the AGI website**\n\n\n" .
	"Sender: " . $sender . "<" . $email . ">\n" .
	"Date: " $date . " " . $time . "\n" .
	"Reply by phone: " . $checkbox . "\n" .
	"Telephone: " . $phone . "\n\n" .
	$subject . "\n" . $msg;

//send the mail + error messages
if(mail($agiemail, $subject, $message, $header))
{
 header('Location: sent.php');
}
else
{
header('Location: emailnotsent.php');
}
?>

 

I keep getting the error message in my browser:

 

Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\agi\_snippets\php\mail.php on line 25

 

Can you guys tell me what I'm doing wrong? I'm running it on localhost using the latest version of xamp. This is my first time working on php.

Link to comment
Share on other sites

I saw a problem and changed it which kind of fixed it but now I'm getting another problem:

 

Edited line:

"Date: " . $date . " " . $time . "\n" .
//forgot the "." before $date

 

New problem:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\agi\_snippets\php\mail.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\agi\_snippets\php\mail.php:31) in D:\xampp\htdocs\agi\_snippets\php\mail.php on line 37 

 

What could this be?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.