0% found this document useful (0 votes)
254 views1 page

PHP Email Form Script

This PHP code configures an email form to send messages to a specified email address. It loads a PHP email form library, sets the receiving email and sender details from POST values, and includes the message content. It also has optional SMTP configuration for sending emails via an external server. On form submission, it sends the email using the PHP email form class.

Uploaded by

Bharat Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
254 views1 page

PHP Email Form Script

This PHP code configures an email form to send messages to a specified email address. It loads a PHP email form library, sets the receiving email and sender details from POST values, and includes the message content. It also has optional SMTP configuration for sending emails via an external server. On form submission, it sends the email using the PHP email form class.

Uploaded by

Bharat Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php

// Replace [email protected] with your real receiving email address


$receiving_email_address = '[email protected]';

if( file_exists($php_email_form = '../assets/vendor/php-email-form/php-email-


form.php' )) {
include( $php_email_form );
} else {
die( 'Unable to load the "PHP Email Form" Library!');
}

$contact = new PHP_Email_Form;


$contact->ajax = true;

$contact->to = $receiving_email_address;
$contact->from_name = $_POST['name'];
$contact->from_email = $_POST['email'];
$contact->subject = $_POST['subject'];

// Uncomment below code if you want to use SMTP to send emails. You need to enter
your correct SMTP credentials
/*
$contact->smtp = array(
'host' => 'example.com',
'username' => 'example',
'password' => 'pass',
'port' => '587'
);
*/

$contact->add_message( $_POST['name'], 'From');


$contact->add_message( $_POST['email'], 'Email');
$contact->add_message( $_POST['message'], 'Message', 10);

echo $contact->send();
?>

You might also like