Hi,

I am getting below error.
"syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING "

1. welcomecaller.php

<form action="send_email_works2.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

2. send_email_works2.php

<?php
$to = "safiullah12@hotmail.com";
$subject = "Brought to you by BenagaliList.com";
$message = "
echo $_POST["fname"];
echo $_POST["age"];

";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <info@bengalilist.com>' . "\r\n";
$headers .= 'Cc: [email]info@bengalilist.com[/email]' . "\r\n";

mail($to,$subject,$message,$headers);
?>

------------------
this is the line, i got error
echo $_POST["fname"];


pls help.

thx.

Recommended Answers

All 12 Replies

$message = "
echo $_POST["fname"];
echo $_POST["age"];

";

what are you doing there? if you want to set $message to the value of fname and age you have to use this code:

$message = $_POST["fname"].$_POST["age"];

that worked. thx.
---------------

Another Request:
1. welcomecaller.php.

<form action="send_email4.php" method="post">
Name: <input type="text" name="fname" />
Email: <input type="text" name="email" />
Phone No: <input type="text" name="phone" />
nn: <input type="text" name="nn" />

<input type="submit" />
</form>

2.send_email4.php

<?php 
$to = "safiullah12@hotmail.com";//  ---A
$subject = "test fname, email,phone,nn";

$message = $_POST["fname"].$_POST["email"].$_POST["phone"].$_POST["nn"];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= $_POST["email"]. "\r\n";//email address A
$headers .= 'Cc: [email]info@bengalilist.com[/email]' . "\r\n";

mail($to,$subject,$message,$headers);
?>

3.I like to send email to email address A from email address B.
Q1. after hitting submit, A should get an email from B(whatever address they entered in #1). tht means, in A's inbox, i want to see B address.i think header section needs to change.
Q2. also, the email CC to 'info@bengalilist.com'. It does CC but shows the email in To box. i want the email address shows in CC field not in TO field.i think header section needs to change.

many thx.

Q1. after hitting submit, A should get an email from B(whatever address they entered in #1). tht means, in A's inbox, i want to see B address as SENDER.i think header section needs to change.

$headers = "From: sender@example.com" . "\r\n" .
'Reply-To: sender@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

sender email can not be hard coded. In the front end(1), customer will enter email address. That email address will be the sender. thx.

I need to use the POST function(i think) for email as below:
$headers .= $_POST["email"]. "\r\n";
$headers .= 'Cc: info@bengalilist.com' . "\r\n";

its not working. Pls help.

thx.

"syntax error, unexpected T_STRING... line17.

line 17 : 'X-Mailer: PHP/' . phpversion();


ran the following code:

<?php 
$to = "safiullah12@hotmail.com";
$subject = "test fname, email,phone,nn";
$Sender = $_POST["email"];
$message = $_POST["fname"].$_POST["email"].$_POST["phone"].$_POST["nn"];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
//$headers .= $_POST["email"]. "\r\n";
//$headers .= 'Cc: [email]info@bengalilist.com[/email]' . "\r\n";
//ff
//dd
$headers = "From: $Sender" . "\r\n" .
'Reply-To: $Sender. "\r\n" .
'X-Mailer: PHP/' . phpversion(); //line 17
mail($to,$subject,$message,$headers);
?>
$headers = "From: ".$Sender . "\r\n" .
'Reply-To: '.$Sender. "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to,$subject,$message,$headers);
?>

check you punctuation

<?php
$to = "safiullah12@hotmail.com";
$subject = "test fname, email,phone,nn";
$Sender = $_POST["email"];
$message = $_POST["fname"].$_POST["email"].$_POST["phone"].$_POST["nn"];
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

$headers = "From: ".$Sender . "\r\n" .
'Reply-To: '.$Sender. "\r\n".
'X-Mailer: PHP/' . phpversion();

mail($to,$subject,$message,$headers);
?>

If i run the above code, i get below error:
SMTP server response: 554 The message was rejected because it contains prohibited virus or spam content in D:\Hosting\7429486\html\safikamila1234xyz456\send_email4.php on line 14

I did google search. And ppl saying its service provider fault.??

Thx a lot.

please mark this thread as solved

Hi,

thx for ur help.

I ran the code once. It works. i get an email in inbox folder. Sender and receiver as expected.
Few hours later, i rant the code again. I was getting 'SMTP SERVER RESPONSE 554-r..rejected because msg has spams.....

i called the service provider. they said $To can not have hotmail or public email. Also, $sender can not be any email user enter in front end. they said change the code another way.i also think he does not know what he is talking about.

After that, i ran again. i got the email in junk folder instead of inbox. Not sure why?

Pls advise.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.