Support Center » Knowledgebase » Send Email from a PHP Script Using SMTP Authentication



 Send Email from a PHP Script Using SMTP Authentication
Solution
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:

<?php
require_once "Mail.php";

$from = "Sender ";
$to = "Recipient ";
$subject = "Subject Here";
$body = "Hi,\n\nHow are you?";

$host = "mail.yourdomain.com";
$username = "Username";
$password = "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!

"); } ?>


Article Details
Article ID: 51
Created On: Oct 04 2006 09:11 AM

 This answer was helpful  This answer was not helpful







home

Support
support center

// www.kionic.com / support center