Mail to external mail service is delivered locally on Plesk server

Follow

Comments

18 comments

  • Avatar
    Keesjan

    You will really like this solution: https://serverfault.com/a/567424 

    Will do for all mailboxes at once...

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Keesjan

    Thank you for the link.

    It may be useful for other Pleskians.

    0
    Comment actions Permalink
  • Avatar
    Geoff Myers

    @Keesjan Thank you for linking to this unofficial solution. It was the only one that actually worked for me.

    0
    Comment actions Permalink
  • Avatar
    Andrea Galizia

    Thank you for the explanation but I am stuck.

    I have several domains, but only one uses an external mail service, let's call it "external.com"

    The mail service is disabled for external.com

    I have checked the postfix configuration and it returns:

         append_dot_mydomain = yes

         mydestination = localhost.$mydomain, localhost, localhost.localdomain

         mydomain = domain.com

    But still, all the emails sent to external.com do not go through.

    Is there something I am missing?

    Thanks in advance for your help.

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hi @Andrea Galizia,

    Have you tried to check the /var/log/maillog file regarding the potential errors?

    If the message is gone to the external mail server but is not delivered to the recipient, it is required to look for the root cause on the external mail server instead of Plesk

    0
    Comment actions Permalink
  • Avatar
    Andrea Galizia

    Hi Nikita,

    yes, and that leads me to the real problem. The emails are bounced back from the external mail server with message "550 Sender domain is a local domain".

    I have noticed that despite the contact form sends with "user@anotherdomain.com" as a sender, Postfix changes it to username@external.com, where username is the subscription user name and external.com is the domain that uses external email server. No matter what I do the sernder is always the same.

    I have moved all the domains from shared hosting with cPanel to VPS with Plesk; only on Plesk this problem happens, on cPanel I have no problems.

    0
    Comment actions Permalink
  • Avatar
    Andrea Galizia

    I think this is my case: https://support.plesk.com/hc/en-us/articles/360002906354-Emails-sent-using-a-PHP-script-use-incorrect-sender-email-address

    But I do not have access to modify WordPress scripts, besides it works fine under cPanel.

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hi @Andrea Galizia,

    Indeed, In Plesk emails via PHP are sent under the system user

    However, possibly this article could help you:

    How to send mail via PHP script using a mailbox located on another server?

    0
    Comment actions Permalink
  • Avatar
    Andrea Galizia

    Hi @Nikita Nikushkin,

    thanks for the solution but the domain uses WordPress, not easy to change the library used for sending emails. Temporarily I have solved by sending the email to a mailbox on another domain hosted on the same server, and the mailbox forward to the external mail server.

    Not an elegant solution but it works.

    Giving the possibility to choose the sender on PHP emails will be nice to have in future Plesk versions, it would save so much time and reduce frustration.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Adrea,

    Thank you for the shared solution and detailed feedback.

    Based on your case, I've created a feature-suggestion to add such functionality to Plesk: https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/38144563-ability-to-set-sender-email-address-from-plesk?

    Feel free to vote for it and comment. The top-rated suggestions are likely to be implemented in the future product versions.

     

    0
    Comment actions Permalink
  • Avatar
    Jay Cee

    Recently used VPS + Plesk as web- & email-Server. Now switched to MS 365/Exchange mail service for that certain Domain, here: domain.com, web service remains on Plesk. Mailservice in Plesk has to be still active for domain.com while used as a backup mailserver / archive clients need to be able to connect to.

    The Problem: Other domains (here: domain-2.com etc) on that VPS/Plesk setup still use the Plesk mail service for email delivery. While there are several email forwardings set up for domain-2.com to the above mentioned domain.com those mails are forwarded and delivered locally, not to MS 365/Exchange's mailservice.

    In short:

    Mails to domain-2.com (with Plesk mail service active and in use) have to be delivered to domain.com (also with Plesk mail service active and in use) with an external mail service running.

    How is this achieved? 

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov (Edited )

    Hi Jay,


    It is not possible. Postfix designed in a way that if the domain is located on local server it will always deliver locally and will never check for MX records, means it will never attempt to send externally.

    0
    Comment actions Permalink
  • Avatar
    K Khan

    Hi, Can anyone answer my query please?

    I've setup Zoho mail Split delivery and changed the MX records to zoho which delivers all incoming mails to zoho first and which emails match with zoho paid ids it delivers there and which do not match it comes to our Plesk Linux server. (We're using VPS)

    Our Scenario-
    We have created two ids(pleskuser@mydomain.com & zohouser@mydomain.com) on Plesk-server and bought professional mailing service from Zoho for id 'zohouser' so, the 'zohouser' id is available both on Plesk-server and Zoho-server.

    Our problem-
    When we send email from our 'pleskuser' to 'zohouser', it delivers to Plesk-server but not on Zoho-server. However, it should deliver to Zoho-server first because we're actively using it.

    Our so far observation-
    It looks that 'pleskuser' id first goes into local mail server to deliver the same domain email.

    Our observed solution-
    If the mails first go for remote mail server then problem could be solved. But, we don't know how to achieve this? If we remove 'local delivery' then those mails will fail which are only hosted on Plesk server and not on zoho.

    Please, suggest the solution.
    It's been 15 days we're hang up.

    0
    Comment actions Permalink
  • Avatar
    Lev Iurev

    @K Khan this scenario will not work. According to its business logic postfix always try to send email locally if recipients domain or mailbox exists on the server.

    You could disable mail service  on the domain - in this case postfix will send email according to its MX record. 

    0
    Comment actions Permalink
  • Avatar
    Harm Jakob Tolsma (Edited )

    We do not include mail service in our subscriptions.
    All our clients have external mail services such as Office 365.

    We noticed that when creating a new subscription, based on a service plan in which the mail service is turned off, the mail service setting is ignored.
    The mail options in the control panel are hidden, which you would expect. But under water, the mail service is still enabled. (tested on Plesk Obsidian Version 18.0.25 Update #2)

    In our case this means that mail from the website will never be delivered to the correct mailserver.

    After starting a telnet session to the server we get the '550 5.1.1 <info@domain.nl>: Recipient address rejected: User unknown in virtual mailbox table' error.
    Only after manually turning off the mail service through SSH, the service is actually disabled for the domain.

     


    telnet 127.0.0.1 25

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    220 servername.nl ESMTP Postfix (Ubuntu)
    EHLO man
    250-servername.nl
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-STARTTLS
    250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
    250-XFORWARD NAME ADDR PROTO HELO SOURCE PORT IDENT
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250-DSN
    250 CHUNKING
    MAIL FROM: <mail-address>
    250 2.1.0 Ok
    RCPT TO: <info@>
    550 5.1.1 <info@>: Recipient address rejected: User unknown in virtual mailbox table


    plesk bin mail --off example.com
    SUCCESS: Turning mail service for domain 'example.com' on/off complete.

    telnet 127.0.0.1 25

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    220 servername.nl ESMTP Postfix (Ubuntu)
    EHLO man
    250-servername.nl
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-STARTTLS
    250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
    250-XFORWARD NAME ADDR PROTO HELO SOURCE PORT IDENT
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250-DSN
    250 CHUNKING
    MAIL FROM: <mail-address>
    250 2.1.0 Ok
    RCPT TO: <info@>
    250 2.1.5 Ok

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello Harm Jakob Tolsma

    This happens because you have mailserver is installed.

    In case, it's not required server-wide, you may remove it from the server via Tools & Settings > Updates.

     

    0
    Comment actions Permalink
  • Avatar
    yann vangampelaere (Edited )

    It's possible to retrieve mail content with message-id ?

     

    I've a lot of message like : relay=plesk_virtual, delay=0.09, delays=0.01/0/0/0.08, dsn=2.0.0, status=sent (delivered via plesk_virtual service)

    And i need find these

    0
    Comment actions Permalink
  • Avatar
    Nico Smit (Edited )

    Hi,

    My few cents on this; If you'd like to disable the email accounts but like to keep sending emails with PHP for example use this: we always run two cronjobs each night (on system user level) and keep the system setting "Enable mail management functions in Plesk" active so we keep the mail queue functionality. 

    Cronjob 1: disable mail service for all domains:
    Command: /usr/sbin/plesk db -Ne"select name from domains" | while read i; do /usr/sbin/plesk bin mail --off $i && echo "Mail service for $i subscription has been disabled" ;done

    Cronjob 2: disable mail service for all domain aliases:
    Command: /usr/sbin/plesk db -Ne"select name from domain_aliases" | while read i; do /usr/sbin/plesk bin domalias -u $i -mail false && echo "Mail service for $i subscription has been disabled";done

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request