How to send Email using PHP with MySQL in Linux Server?..

Answer Posted / karthi

PHP Code
The PHP code to send email is simply one PHP function mail
() . The basic format for this function is:
mail("to", "subject", "message");

For example (this is straight out of the online help that
comes with PHP):
mail("joecool@example.com", "My Subject", "Line 1\nLine 2
\nLine 3");
PHP does need to be installed and setup properly for mail
to work. On a Unix-type setup, such as Linux, PHP will use
your local sendmail program to send it. Windows machines
use SMTP. If you need to you can edit your php.ini file and
set the appropiate SMTP host you use to send email.
Here's the code to send the email:
if ($REQUEST_METHOD == "POST") {
// Just to be on the safe side - I'll strip out HTML tags
// (scripting code may mess with some email clients)
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
// setup variables
$sendto = "$email";
$subject = "Send Mail Feedback Using PHP";
$message = "$realname, $email\n\n$feedback";
// send email
mail($sendto, $subject, $message);
}
?>

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does php work?

531


Applications written to provide a GUI shell for Unix and Linux are called

571


How you can update memcached when you make changes to php?

613


What are the different ways to login to a remote server?

477


How can we set and destroy the cookie in php?

488






Is php used in 2019?

527


Do I need apache for php?

613


What is a namespace in php?

471


Why php is widely used?

539


How do I display php errors?

510


What is the difference between $var and $$var?

548


Does session expire on closing browser?

485


Do you know design patterns. List few?

530


What is the difference between exception::getmessage and exception::getline?

529


How to find a specific value in an array?

502