How to Send PHP Mail with Authentication
You can download a fully functional PHP Contact Form for your Website at: Contact Form with PHP Email to Send Email from your Website
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. Replace "firstname.lastname@example.org"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.
For the $host variable, please replace "smtp.YourDomain.com" with your own domain's smtp address.
require_once "Mail.php"; //Mail.php is already installed on the Web Server. You do not need to upload this file
$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);
echo("" . $mail->getMessage() . "");
echo("Message successfully sent!");
How to send HTML mails using PEAR Mail
To send HTML Mail, please add the following line to your PHP code to include mime features.
require_once "Mail/mime.php"; //mime.php is already installed on the Web Server. You do not need to upload this file
Please see below for an example code of how to send HTML emails using PEAR Mail
require_once ("Mail/mime.php"); //mime.php is already installed on the Web Server. You do not need to upload this file
$from = "Matha Sender <email@example.com>";
$to = "James Recipient <firstname.lastname@example.org>";
$subject = "Hi! This is the HTML Mail example";
$host = "smtp.YourDomain.com"; //replace this with your domain's SMTP address
$port = '25';
$username = "email@example.com";
$password = "Put your firstname.lastname@example.org password here";
$text = "Hello, How are you doing?";
$html_message = "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>HTML Email Test Page</title>
<p>Hello, How are you doing?</p>
$headers['From'] = $from;
$headers['To'] = $to;
$headers['Subject'] = $subject;
$headers['Content-Type'] = 'text/html; charset=UTF-8';
$mime = new Mail_mime;
//$mimeparams['debug'] = 'True'; //Uncomment this if you want to view Debug information
$body = $mime->get($mimeparams);
$headers = $mime->headers($headers);
$smtpinfo['host'] = $host;
$smtpinfo['port'] = $port;
$smtpinfo['auth'] = true;
$smtpinfo['username'] = $username;
$smtpinfo['password'] = $password;
//$smtpinfo['debug'] = 'True'; //Uncomment this if you want to view Debug information
$mail=& Mail::factory('smtp', $smtpinfo);
$mail->send($to, $headers, $body);
Please visit the following link for full documentation and examples of how to send HTML Emails using the installed Pear Mail_Mine.
Pear Mail Mime Documentation and Examples
Was this answer helpful?
By default and for security reasons, all the folders in your web hosting space are read-only. For...
Our IIS 7.5 Web Hosting Servers has installed a third party tool, Helicon Ape, to provide the...
Displaying PHP Errors are turn off by default. However, you can turn on/off Displaying...
Dear Sir, Your sender of the Email address must be an email address that is hosted on our...
Click on the following link to download a fully functional PHP Contact Form that you can upload...