Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- @require_once('Mail.php');
- // Check for empty fields
- if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) ||
- empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) {
- echo "No arguments Provided!";
- return false;
- }
- // This configures the host information
- $from = "NoReply <noreply@rooshivkumar.com>";
- $to = "roo@rooshivkumar.com";
- $host = "ssl://send.one.com";
- $port = "465";
- $username = "noreply@rooshivkumar.com";
- $password = "";
- // Get file information
- $handler = fopen("config/10bdac23491231001239439234adbecadbc.cfg", "r");
- if ($handler) {
- $password = base64_decode(base64_decode(fgets($handler)));
- fclose($handler);
- }
- else {
- echo "Failed to log into SMTP server to send information";
- return false;
- }
- $name = $_POST['name'];
- $email_address = $_POST['email'];
- $phone = $_POST['phone'];
- $message = $_POST['message'];
- // Create the email and send the message
- $email_subject = "Website Contact Form: $name";
- $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
- $headers = array ('From' => $from,
- 'To' => $to,
- 'Subject' => $email_subject);
- $smtp = @Mail::factory('smtp',
- array('host' => $host,
- 'port' => $port,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password
- )
- );
- $mail = @$smtp->send($to, $headers, $email_body);
- if ($mail != 1) {
- echo "Unable to send contact information.";
- return false;
- }
- echo "Your request was successful";
- return true;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement