Sign Up / Log In
Need help?
800 130 1651
Online Support Windows Hosting

How to add PHPMailer for Windows Hosting in Plesk

What is PHPMailer?

PHPMailer is an open-source library for the PHP scripting language that enables the capability for securely sending email via a web server. This was initially developed by Brent R. Matzelle in 2001 as a project for SourceForge.

The capability of PHPMailer to transport emails comes from the PHP mail() function embedded within its application. PHP mail() function is the actual script that enables the SMTP functionality of PHPMailer.

When you have installed PHPMailer in your site, its code can be found in a .php file.

What can you do with PHPMailer?

With PHPMailer you can do the following tasks in PHP:

  • Send HTML emails
  • Send emails with attachments
  • Send emails via Gmail
  • Send emails using your own SMTP Server
  • Send emails to multiple recipients all at once

Note: Our mail server is not open relay, which means that authorization is always needed in PHPMailer config.

How to add PHPMailer for Windows Hosting in Plesk

You will need to first, search for and download PHPMailer. Make sure to get it from a reliable source.

Important Note: In order to use PHPMailer, you will need a domain name and web hosting, which you will be using to set up a working email account. If you want to test the script, then create two email accounts: a sender and a recipient.

If you want to know how to create a personal email account in Plesk, click here.

After downloading, you can add PHPMailer for your Windows Hosting in Plesk by following the instructions below:

  1. Click Sign Up / Log In at the top of this page.
  2. Select Hosting Manager frmom the drop-down menu.
  3. Enter your hosting username and password, then click Log In.
  4. Click Files from the left-side menu.
  5. Under File Manager, click on the httpdocs folder to open it.
  6. Within the httpdocs folder, click on the + New button at the top and select Create Directory to create a new folder.
  7. You can name it PHPMailer00 or anything you prefer, then click OK.
  8. Open that new folder by clicking on it.
  9. Inside the new folder, click on the Upload button at the top to upload the PHPMailer zipped folder you downloaded earlier.
  10. Right-click on the zipped folder and extract the files.
  11. Click on the extracted folder to open it. You can get a simple sample script inside the README.md file.
    Or you can just use the simple sample script below:
    
        <?php
          
            require 'PHPMailer00/class.phpmailer.php'; // filepath to the PHPMailer class
            require 'PHPMailer00/class.smtp.php';
    
            $mail = new PHPMailer();
    
            $mail->SMTPDebug = 2;
            $mail->Mailer = "smtp";
            $mail->Host = "localhost";
            $mail->Port = 587;
            $mail->SMTPAuth = true; // turn on SMTP authentication
            $mail->Username = "sender@yourdomain.com"; // SMTP username
            $mail->Password = "password123"; // SMTP password 
            $Mail->Priority = 1;
    
            $mail->AddAddress("recipient@theirdomain.com","Name");
            $mail->SetFrom("info@yourdomain.com", "Info");
            $mail->AddReplyTo("info@yourdomain.com", "Info");
    
            $mail->Subject  = "Hello";
            $mail->Body     = "This is my message.";
            $mail->WordWrap = 50;  
    
            if(!$mail->Send()) {
            echo 'Message was not sent.';
            echo 'Mailer error: ' . $mail->ErrorInfo;
            } else {
            echo 'Message has been sent.';
            }
    
        ?>
        

    Note: Make sure to include the closing tags (?>) at the bottom.

  12. Click on the + New button at the top and select Create File to create a new .php file (e.g. test01.php), then click OK to save it in the same folder as the extracted PHPMailer folder.
  13. Click on the new file to open it then paste the sample script here.
  14. Replace the following values with your own and click OK to save:
    File path The path of the file that will perform the action or function required for PHPMailer to send emails.
    Host Your email hosting server.
    Username Your hosting username.
    Password The Corresponding login password for your hosting.
    SetFrom The email address you want the recipient to see as the sender.
    AddAddress The email address of the recipient.
    AddReplyto The email address you want the recipient to reply to.
    Subject The subject of your email.
    Body The body or main content of your email.
    As an alternative to the PHPMailer script, you can also use the simple PHPMail script below instead:
    
        <?php
            $to      = 'recipient@theirdomain.com';
            $subject = 'Email Test';
            $message = 'Hello World';
            $headers = 'From: sender@yourdomain.com' . "\r\n" .
                'CC: info@theirdomain.com';
                'Reply-To: info@yourdomain.com' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();
            
            mail($to, $subject, $message, $headers);
            echo "Message has been sent.";
        ?>
        
  15. Test if the script works by checking it out on your browser. To do this, put the following url in your address bar:
    
        yourdomainname.com/folder name/filename.php
        
  16. If everything is in order and the script works, you will see the following message:
    
        Message has been sent.
        

Note: Also check your recipient email inbox. If you got an email from "sender@yourdomain.com" and it has the message you put in the "body" tag ("This is your message."), then the script works.

Congratulations! You have successfully added PHPMailer for Windows Hosting in Plesk.

Was this helpful? Yes No 67% of people found this helpful.
we're
online
Need Help? Chat Now