[Settings] Fix for SMTP AUTH issue in mailer.php

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
tnuz
Posts: 1
Joined: Wed Feb 12, 2014 2:02 pm

[Settings] Fix for SMTP AUTH issue in mailer.php

Post by tnuz »

I had an issue that the SMTP mail function in the Settings plugin failed. The SMAP server replied with:

Code: Select all

503 AUTH command used when not advertised
This seems to be the result of using HELO instead of EHLO when starting the SMTP conversation.

Some debugging lead me to the '_send_mail' function in cacti/plugins/settings/include/mailer.php
I changed some code starting on line 749 in this file.

The original code was:

Code: Select all

/* Start SMTP conversation */
fputs($smtp_sock, "HELO " . $this->Config["Hostname"] . "\r\n");
$smtp_response = fgets($smtp_sock, 4096);
if (substr($smtp_response,0,3) != "250") {
    $this->Error = "Error returned by SMTP host: " . $smtp_response;
    fclose($smtp_sock);
    return false;
}
I changed it to:

Code: Select all

/* Start SMTP conversation */
fputs($smtp_sock, "EHLO " . $this->Config["Hostname"] . "\r\n");
$smtp_response = fgets($smtp_sock, 4096);
if (substr($smtp_response,0,3) != "250") {
    $this->Error = "Error returned by SMTP host: " . $smtp_response;
    fclose($smtp_sock);
    return false;
}
while (trim($smtp_response) != "250 HELP") {
    $smtp_response = fgets($smtp_sock, 4096);
}
Hopefully this will help anyone that experiences the same issue.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests