• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Domain can't send emails

Irolan

New Pleskian
Hello,
weird problem here.
We're running a Plesk 12.5.30 Update #41 on CentOS Linux 7.1.1503 (Core). There's several domains on the system, all of which work fine, but one. A certain domain does not permit sending emails.
The emails are Office365, so they're not Plesk - the email server function is turned off for the domain.
Drupal is installed on the domain, but it's not a Drupal problem - I tested the mail function using this script:
PHP:
<?php
$to = "[email protected]";
$subject = "Test Mail";
$message = "This is a test";
$from = "[email protected]";
$headers = "From:".$from;
if(mail($to, $subject, $message, $headers)){
    echo "Mail sent.";
}
else{
    echo "Error";
}
?>
It returns "Error".
There's nothing in the protocols.
Does anyone have an idea what might be the problem?
 
Try to send out with SMTP the emails.

Anyway, check 2 things.
- in Server-Wide Mail Settings check if you allow to send out with sendmail email, like: Allow users and scripts to use Sendmail
- Email services are active for the domain.

Always check the error_logs to see what can be the reason.
 
Try to send out with SMTP the emails.
How?

Anyway, check 2 things.
- in Server-Wide Mail Settings check if you allow to send out with sendmail email, like: Allow users and scripts to use Sendmail
- Email services are active for the domain.
Users and scripts are allowed to use sendmail, that option is active.
The email services for the domain in question are deactivated - that's intentional as there are no email addresses set up for the domain in Plesk. They're in Office365. I activated the email services anyway as a test - no change. Also, there are two other domains with a similar setup (emails are Office365, email services in plesk are deactivated) and they work.

Always check the error_logs to see what can be the reason.
Unless there's additional logs I don't know about, there's nothing there. I checked under "protocols" in the domain settings - it shows when the test.php with the mail script was accessed, but nothing further.
Drupal only says that an error has occured and the email could not be sent, but not what the error was.
 
I do not use Drupal, but with a simple search I think you can find the answer. For ex: http://www.symphonythemes.com/drupal-blog/configure-drupal-smtp-gmail

About error_log, you can check your domain error_log and server maillog, somewhere need to be a clue about why emails are not sending out.

This is not a Drupal issue. I tried the SMTP mailer module for Drupal, still the same problem. It says there was an error.
I could not find anything in the error logs of the domain. The mail log is not available because the mail services are turned off for the domain.
 
If you have tried the SMTP mailer, then probably you are using your external services. Then it is not connected anymore to your server.
What are the settings used for SMTP? Server, port, etc (do not copy the password or replace also the domain.)
 
If you have tried the SMTP mailer, then probably you are using your external services. Then it is not connected anymore to your server.
What are the settings used for SMTP? Server, port, etc (do not copy the password or replace also the domain.)

Username and password for SMTP are the email (in this case [email protected]) and password of the Office365 account.
SMTP server is smtp.office365.com
Outgoing port is 587
I tried both SSL and TLS.
 
Then this means that you are using an external service. If you do not get back errors in Drupal, then I do not see how you can debug it. You should get back the server response, which should be in some Drupal logs and you must see there the issue. PLESK/Server does not have anything to do with it in my opinion. It is same like you are using a mail software. Mail software always show to you an error, like invalid password or cannot connect to server or etc.
If you have tried port SSL and TLS also you need to be sure you have a certificate accepted or you will get error. Try to find some errors in Drupal Log.
 
Then this means that you are using an external service. If you do not get back errors in Drupal, then I do not see how you can debug it. You should get back the server response, which should be in some Drupal logs and you must see there the issue. PLESK/Server does not have anything to do with it in my opinion. It is same like you are using a mail software. Mail software always show to you an error, like invalid password or cannot connect to server or etc.
If you have tried port SSL and TLS also you need to be sure you have a certificate accepted or you will get error. Try to find some errors in Drupal Log.

Well, it is not Drupal. As you can see in my initial post, I tried a script. This script was simply a PHP file accessed via http://mydomain.de/test.php and it did not work. If it was a problem with Drupal, the the script would stikk work.
The Drupal log also only states "There was an error while sending the email. Please contact you web administrator."
I'll try to find if there's any problem with Office365. But everything else seems to work there as well.
 
In your test script you are not using SMTP, in this case you can see errors in maillog and error_log.

If you are using SMTP in other script then you need to get back an error.

It is hard to know like this what you are doing, or also to tell to you where is the error. Eventually contact me on PM and I will try to help you out.
 
Here is an example PHP script, with SMTP - AUTH - functionality for OFFICE365 ( pls. adjust the EXAMPLE - entries, if you want this script to work as expected! ;) ), which you could place temporarily in the docroot - of your domain/subdomain ( for example at "/var/www/vhosts/YOUR-DOMAIN.COM/httpdocs/test-phpmail.php" ).

Code:
<?php
    require_once('/usr/share/php/Mail.php');

    $from = "FROM-EXAMPLE-FIRST-NAME FROM-EXAMPLE-LAST-NAME <[email protected]>";
    $to = "TO-EXAMPLE-FIRST-NAME TO-EXAMPLE-LAST-NAME  <[email protected]>";
    $bcc = '';
    $subject = "TEST - eMail with PHPmail - usage";
    $body = "SUCCESS,\n\nYOU SUCCESSFULLY RECEIVED AN EMAIL WITH PHPmail AND OFFICE365.";

    $host = 'smtp.office365.com';
    $port = '587';
    $username = 'EXAMPLE-OFFICE365-AUTH-USERNAME';
    $password = 'EXAMPLE-OFFICE365-AUTH-PASSWORD-FOR-THE-CONFIGURED-OFFICE365-EMAIL-ADRESS';

    $headers = array(
    'Port'          => $port,
    'From'          => $from,
    'To'            => $to,
    'Subject'       => $subject,
    'Content-Type'  => 'text/html; charset=UTF-8'
    );

    $recipients = $to.", ".$bcc;

    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

    $mail = $smtp->send($recipients, $headers, $body);

    echo "test";

    if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
    } else {
    echo("<p>Message successfully sent!</p>");
    }

?>

Depending log - entries will be written to to "/var/log/maillog"
 
Last edited by a moderator:
The emails are Office365, so they're not Plesk - the email server function is turned off for the domain.

When you turn email server functions off, there is a chance, that email server functions might not work. I suggest turning email server functions on for your domain.

I also second UFHH01. With Office365 and your local mail functionality turned off, you should use the Office365 SMTP gateway to send mail from your domain.
 
We have same problem like author :((
After upgrading to 12.5.3 phpmail() stopped works. I also had created php test mailscript and it doesn't send mails. And also no any log! Very strange.
If I access http://mydomain.com/mailtest.php via web - script executes but doesn't send anything anywhere. But if I access this script via ssh like
#ssh mailtest.php
it sends mail without any problems.
I had tried different php versions - same! No logs, no mails. Before upgrading everything worked!
----------
Allow users and scripts to use Sendmail: YES
Email services are active for the domain: YES
 
Irolan,
I had the problem that similar to yours and now this issue is solved thanks to professionals from my hosting company. The problem with mail was caused by changed SELinux enforcement mode after Plesk upgrading.
After Plesk upgrading it become "enforcing" itself so mailscript couldn't access mail service as I could undestand. After change enforcement mode to "permissive" (disable) my mail scripts again works.
Please try and confirm that you have same problem?
Regards, Sultansha.
 
Sorry for necroing the post. I just wanted to add this in case someone else has the same problem.
The solution was found by our provider. The problem only occurred when the sites were set to FPM. It worked when set to FastCGI. Something was missing in the FPM installation. They added it, then it worked.
 
Hi Irolan,

Something was missing in the FPM installation. They added it, then it worked.
Thank you very much, for your post, but don't you think it would help much more, if you provide the information(s) WHAT has been changed? At the moment, you are just pushing a thread from Sept. 2016, which may not be relevant at all anymore, due to updates/upgrades and patches. :(
 
Back
Top