• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Unable to Send Emails Using PHPMailer on Plesk Server

bboyjackson

New Pleskian
Hi everyone,

I am trying to send emails from my website using PHPMailer with my Plesk server's SMTP configuration. However, the emails are not being sent, and I am unsure if my configuration is correct or if something else needs to be enabled in Plesk.

Here is the code I am using for testing purposes:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

$mail = new PHPMailer(true);

try {
// SMTP configuration
$mail->isSMTP();
$mail->Host = 'mail.tiptoplaptop.nl'; // SMTP server of my domain
$mail->SMTPAuth = true;
$mail->Username = '[email protected]'; // My email address
$mail->Password = '*****'; // My password (hidden for security)
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;

// Sender
$mail->setFrom('[email protected]', 'TipTop Laptop');

// Receiver
$mail->addAddress('[email protected]'); // Test recipient

// Email content
$mail->isHTML(true);
$mail->Subject = 'Test email to Gmail';
$mail->Body = '<h1>This is a test</h1><p>Email sent successfully!</p>';

// Send email
$mail->send();
echo 'Email sent successfully!';
} catch (Exception $e) {
echo "Email could not be sent. Error: {$mail->ErrorInfo}";
}

?>

The Problem:​

  • The email is not being sent.
  • I am not receiving any error messages, or sometimes I see this: SMTP connect() failed.

Additional Information:​

  • My domain: tiptoplaptop.nl
  • Plesk settings seem correct (SMTP is enabled).
  • My DNS records include SPF, DKIM, and DMARC.
  • I am testing with a Gmail address as the recipient ([email protected]).

Question:​

  1. Is there anything additional I need to configure in Plesk for this to work?
  2. Are there known limitations or restrictions with outgoing mail that I need to check?
  3. How can I troubleshoot this issue further?
Thank you in advance for your help!
 
If you're using Plesk's email settings then it's more likely because of the fact that you do not have an A record configured for mail.tiptoplaptop.nl

Code:
╭─ pwsh        126ms⠀                                                                                             27,08:39 
╰─ dig mail.tiptoplaptop.nl

; <<>> DiG 9.16.28 <<>> mail.tiptoplaptop.nl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 867
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;mail.tiptoplaptop.nl.          IN      A

;; AUTHORITY SECTION:
tiptoplaptop.nl.        1800    IN      SOA     alan.ns.cloudflare.com. dns.cloudflare.com. 2362010970 10000 2400 604800 1800

;; Query time: 25 msec
;; SERVER: 192.168.2.51#53(192.168.2.51)
;; WHEN: Mon Jan 27 08:39:19 US Mountain Standard Time 2025
;; MSG SIZE  rcvd: 111

╭─ pwsh        136ms⠀                                                                                             27,08:39 
╰─ dig -t aaaa mail.tiptoplaptop.nl

; <<>> DiG 9.16.28 <<>> -t aaaa mail.tiptoplaptop.nl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 591
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;mail.tiptoplaptop.nl.          IN      AAAA

;; AUTHORITY SECTION:
tiptoplaptop.nl.        1777    IN      SOA     alan.ns.cloudflare.com. dns.cloudflare.com. 2362010970 10000 2400 604800 1800

;; Query time: 0 msec
;; SERVER: 192.168.2.51#53(192.168.2.51)
;; WHEN: Mon Jan 27 08:39:41 US Mountain Standard Time 2025
;; MSG SIZE  rcvd: 140

╭─ pwsh        116ms⠀                                                                                             27,08:39 
╰─ dig -t aaaa mail.tiptoplaptop.nl "@8.8.8.8"

; <<>> DiG 9.16.28 <<>> -t aaaa mail.tiptoplaptop.nl @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55460
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;mail.tiptoplaptop.nl.          IN      AAAA

;; AUTHORITY SECTION:
tiptoplaptop.nl.        1800    IN      SOA     alan.ns.cloudflare.com. dns.cloudflare.com. 2362010970 10000 2400 604800 1800

;; Query time: 19 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Jan 27 08:39:50 US Mountain Standard Time 2025
;; MSG SIZE  rcvd: 111

╭─ pwsh        130ms⠀                                                                                             27,08:39 
╰─ dig -t ns tiptoplaptop.nl

; <<>> DiG 9.16.28 <<>> -t ns tiptoplaptop.nl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30707
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;tiptoplaptop.nl.               IN      NS

;; ANSWER SECTION:
tiptoplaptop.nl.        86400   IN      NS      alan.ns.cloudflare.com.
tiptoplaptop.nl.        86400   IN      NS      holly.ns.cloudflare.com.

;; Query time: 43 msec
;; SERVER: 192.168.2.51#53(192.168.2.51)
;; WHEN: Mon Jan 27 08:40:04 US Mountain Standard Time 2025
;; MSG SIZE  rcvd: 100

╭─ pwsh        158ms⠀                                                                                             27,08:40 
╰─ dig -t mx mail.tiptoplaptop.nl

; <<>> DiG 9.16.28 <<>> -t mx mail.tiptoplaptop.nl
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 46348
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;mail.tiptoplaptop.nl.          IN      MX

;; AUTHORITY SECTION:
tiptoplaptop.nl.        1736    IN      SOA     alan.ns.cloudflare.com. dns.cloudflare.com. 2362010970 10000 2400 604800 1800

;; Query time: 2 msec
;; SERVER: 192.168.2.51#53(192.168.2.51)
;; WHEN: Mon Jan 27 08:40:23 US Mountain Standard Time 2025
;; MSG SIZE  rcvd: 140

Since you're using cloudflare for DNS you will need to make sure that the DNS settings are set properly for the subdomain. Which means your SPF record will need to be updated to allow from your web server since that's how you're trying to send from as well.

In either case, I noticed your MX record for tiptoplaptop.nl uses google apps, why not configure the SMTP to utilize that instead? Would save you the hassle of having to configure the DNS settings since it's already configured for google apps to begin with.
 
Ooh! This is for the website tiptoptelecom.nl! So I want to use the mail from tiptoplaptop for tiptoptelecom.

So, at this moment I just need to use the smtp for tiptoplaptop?
 
You will still need to have an A record configured for whatever domain you're using for the smtp settings for it to connect to. So even though the domain is for tiptoptelecom.nl but you want to use tiptoplaptop.nl for the emails if you're self hosting the SMTP you will still need the A record configured for whatever the SMTP record. This is also the reason why I said to just use Google Workspace's settings since I see based off the MX records that you're using Google Workspace for emails. Refer to Send email from a printer, scanner, or app - Google Workspace Admin Help for setting it up.
 
Back
Top