|
How to Send Emails from your Website using PHP
Utiware's SMTP Email Servers require authentication before emails can be sent. Please use the following PHP emailing script to see how to include SMTP authentication in your PHP code. Please replace "username@yourdomain.com" with your email address, and use its corresponding password for authentication.
<?php
require_once "Mail.php";
$from = "Sandra Sender <username@yourdomain.com>";
$to = "Ramona Recipient <receiver@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you doing?";
$host = "localhost";
$username = "username@yourdomain.com";
$password = "Put your username@yourdomain.com password here";
$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("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
|