EEECS Logo
Self-Service Online

LAMP Web Hosting - PHP Sending Email

Overview & Example

A short PDF QuickStart guide is available with an annotated PHP example to allow you to get setup quickly and test sending an email to yourself.
EEECS-Hosting-PHP-Mail.pdf
Help guide

Download PHPMailer example

The example in the guide and PHPMailer library are available for download. Just change the placeholders to use your email account details and copy to the server and test.

PHPMailer Example QUB-PHP-Email-Send.zip

PHPMailer

A full-featured email creation and transfer class for PHP.

PHPMailer library allows you to send via SMTP and make use of features such as encryption, authentication, HTML messages, and attachments.

PHPMailer Logo



To send mails from your PHP application code follow the steps:

Use the QUB SMTP Server

  1. You need to use your QUB email address to send an email from PHP.
  2. You can send an email using the QUB smtp server smtp.qub.ac.uk
  3. Alternatively you could use an external email such as gmail but will need to authenticate using your account

Example PHP Code - modify it to test

In the example phpmailersend.php - you need to replace the placeholders with your details:

<SENDEREMAILADDRESS> your QUB email address
<SENDERNAME> your name or app name
<RECIPENTEMAIL> a test email address to send to - use your qub email address to test
<RECIPIENTNAME> a recipient name to test with

FTP the Example & PHPMailer lib folder to your web hosting

Make sure the paths are correct to the PHPMailer files.
You can set errors to verbose in the example by uncommenting the line

//$mail->SMTPDebug = 3;