Prolateral Consulting Ltd
Prolateral Consulting Ltd
Knowledgebase: outmail
How do I set up outbound SMTP using PEAR::Mail?


How do I set up outbound SMTP using PEAR::Mail?


The following example of code shows you how to send an email using outMail as the SMTP SmartHost mail relay using the PEAR::Mail module for php.

outMail is an authenticated SMTP relay so the example below shows authentication in php as well. The code below uses the default SMTP port 25 but it can easily be changed to an alternative SMTP port by editing the line code $mail_params['port'].

Example code smtp-test.php

  <title>SMTP Test using PEAR::Mail in PHP</title>


// set the recipients (to) address [REQUIRED]
$mail_to                 = '';

// set the mail headers which include sender address, subject, etc
$mail_headers['From']    = '';
$mail_headers['To']      = $mail_to;
$mail_headers['Subject'] = 'Test message';

// set the mail content
$mail_body               = "The test messsage is having this body line inside.";

// set the smtp mail server [REQUIRED]
$mail_params['host']     = '';
$mail_params['port']     = 25;    // Can use alternative ports if needed (See below)
$mail_params['auth']     = 'PLAIN';
$mail_params['username'] = 'outmail-username'; 
$mail_params['password'] = 'outmail-password';

// optional SMTP debug options
// $mail_params['debug'] = true;

// Create the mail object using Mail::factory
$mail_object =& Mail::factory('smtp', $mail_params);

// Send the message
$mail_object->send($mail_to, $mail_headers, $mail_body);


Summary of server details

Outgoing server

As provided in your signup email.

Outgoing server protocol


Outgoing server port

25, 587, 2525 or 8025

Authentication Type

Basic Authentication


As provided


As provided


(0 vote(s))
Not helpful

The Origin of this information may be internal or external to Prolateral Consulting Ltd. Prolateral makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Prolateral makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.