Utiware Web Hosting
Please Login or Register

Knowledgebase

How to Send PHP Mail with Authentication

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 valid email address that is hosted on our server, and use its corresponding password for authentication.  Our Email Servers will not send emails on behalf of random people,so this is why the Sender of the email must match EXACTLY the email address that is used for SMTP Authentication.

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 = "74.126.82.37";
$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("

"

. $mail->getMessage() . "

");
 } else {
  echo("

Message successfully sent!

"
);
 }
?>

 

 



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read

Language:

Quick Navigation

Client Login

Email

Password

Remember Me

Search