Form Mail php for Windows Server

This is php form mail script for Windows server which mail ids configure with your own Hosting control panel.

<?php
require_once "Mail.php";
$from = "Sandra Sender <test@yourdomain.com>";
$to = "Ramona Recipient <test2@yourdomain.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "localhost";
$username = "test@yourdomain.com";
$password = "1234";
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
  echo("

" . $mail->getMessage() . "

");
 } else {
  echo("

Message successfully sent!

");
 }
?>

 

 

This is php form mail script for Windows server which mail ids configure with Google Apps or Gmail.

<?php
require_once "Mail.php";
$from = "Sandra Sender <test@yourdomain.com>";
$to = "Ramona Recipient <test2@yourdomain.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "test@yourdomain.com";
$password = "1234";
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
 'port' => $port,
    'username' => $username,
    'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
  echo("

" . $mail->getMessage() . "

");
 } else {
  echo("

Message successfully sent!

");
 }
?>

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Form Mail .net

In web.config File   <system.net>    <mailSettings>      <smtp>...

PHP Form Mail For Linux Server using SMTP authentication

Send Email from a PHP Script Using SMTP AuthenticationTo connect to an outgoing SMTP server from...

ZOHO Form Mail

This is PHP form mail script for Linux server where mail ids are configured with ZOHO Mail....