If you want to send email from Hostgator command line there here is the working sample.
Just replace from email id, to email id, host,username and password.
<?php
require_once "Mail.php";
$from = "contactus@mysite.com";
$to = "to email id";
$subject = "this is the message from your domain";
$body = "give your message body here";
$host = "mail.mysite.com";
$username = "contactus+mysite.com";
$password = "pass123";
$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 Sent successfully"); }
?>
No comments:
Post a Comment