Click here to Skip to main content
15,125,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

I am sending a simple mail.. but it's not sending. When I use simple mail function without variable direct text then it's sending properly but when I use a variable then it's not sending mail and not giving any error.

please suggest me help.

What I have tried:



NOT Working -----------------------
All variables are properly received and printing. but mail not sending..


	$name = $_POST['name'];
	$email = $_POST['email'];
	$address = $_POST['address'];
	$contact = $_POST['contact'];
	$city = $_POST['city'];
	$comment = $_POST['comment'];

echo $name . " | " . $email . " | " . $address . " | " . $contact . " | " .$city . " | " . $comment;

$subject = 'Hi We have a message from ' . $name;

echo $subject;

Updated 11-Jan-18 4:10am
EZW 14-Jan-18 0:08am
Just in case FYI: Mail doesn't work (usually) on a localserver. You need a domain with available services for mail to work. SMTP/POP server, something like that. Not sure for certain. All competitive host would have mail working.

1 solution

Does $name contain non ASCII characters?

Then the subject must be encoded as noted in the PHP: mail - Manual[^]:
Caution Subject must satisfy » RFC 2047[^].

Example to create an encoded subject string:
$encoded_subject = "=?UTF-8?Q?".quoted_printable_encode($subject)."?="

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900