Prolateral Consulting Ltd
Prolateral Consulting Ltd
Support
Support
Knowledgebase Articles
Help
Setup examples
Support

Prolateral offers primary and backup domain (DNS) services, with servers in key geographic locations providing the best service possible.

Problem

How do I set up outbound SMTP using PHPMailer?
How do I use outMail in PHP?

Solution

The following example of code assumes you have already got a fully functional webserver and the PHPMailer Classes Installed (see https://github.com/PHPMailer )

Example code outmail-phpmailer.php


<?php
	require_once("class.phpmailer.php" );
	$mail = new PHPMailer(true);    // the true param throws exceptions that we need to catch
	$mail->IsSMTP();             // telling the class to use SMTP
	try {
		// Enables SMTP debug information (for testing)
		//    1 = errors and messages
		//    2 = messages only
		$mail->SMTPDebug = 1;                    

		// Enable SMTP authentication
		$mail->SMTPAuth = true;
        
		// SMTP server
		$mail->Host = "mxXXXXXX.smtp-engine.com";   

		// set the SMTP port for the outMail server        
		//    use either 25, 587, 2525 or 8025
		$mail->Port = 25;

		// outMail username        
		$mail->Username = "username";
        
		// outMail password
		$mail->Password = "password";
        
		// Message details
		$mail->AddReplyTo('me@example.com', 'First Last');
		$mail->AddAddress('sender@there-domain.local', 'First Last');
		$mail->SetFrom('me@example.com', 'First Last');
		$mail->Subject = 'PHPMailer Test using outMail';
		$mail->AltBody = 'Text Message goes here.';
		$mail->MsgHTML('HTML Message goes here.');
        
		// Send the Message
		$mail->Send();
        
		echo "Message Sent OK</p>\n";
	}
    
	catch (phpmailerException $e){echo $e->errorMessage();} //Pretty error msg from PHPMailer
    
	catch (Exception $e){echo $e->getMessage();} //Boring error messages from anything else!

 

Summary of server details

Outgoing server

mxXXXXXX.smtp-engine.com

As provided in your signup email.

Outgoing server protocol

SMTP

Outgoing server port

25, 465, 587, 2525 or 8025

Authentication Type

Basic Authentication, SSL and TLS supported

Username

As provided

Password

As provided

like it, love it, then share it. Share this article on social media.

Did you enjoy this article?

Disclaimer

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.