Home Hosting Domains IT Services Support Contact Us
MyAccount PortalClient AreaAnnouncementsKnowledgebaseSupport TicketsDownloads

Knowledgebase
You are here: MyAccount Portal > Knowledgebase > Web Development & Coding > How do I send email with a PHP script?

How do I send email with a PHP script?

Please use the PHP Pear mail authentication,
this is to prevent spammer to access the php normal mail() function which is insecure.

Please download the package on http://pear.php.net/package/Mail
and then copy it to your working folder on the webserver
After that you have to include the files on your PHP Please refer to this for more reference. 

By default, user 'nobody' is disabled in our servers.

To send emails from a PHP script, please code
your PHP script using SMTP authentication.

If you are using a PHP forum or a PHP script with emailing capability, please be sure to configure
your script with SMTP Mail in order to send emails.

SMTP Details:
Host: mail.yourdomain.com
Port: 25
Username: your email account username (can be username@yourdomain.com)
Password: your email account password

Web Contact Forms: Here is an example of a PHP Script using SMTP Authentication:

require_once "Mail.php";

$from = "You ";
$to = "Recipient ";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$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
Print this Article

Also Read


Network Status Client Area Knowledgebase Datacentre  
 
Terms of ServicePrivacy PolicyCustomer Security