Skip to content

php error when trigger threshold sendmail  #3380

Closed

Description

@yingbaiibm

To Reproduce
Steps to reproduce the behavior:

  1. Create multiple threshold and trigger them to sendmail to user
  2. After trigger, check mail, only receive one mail.
  3. Check Log, error exist and garbled log exist

2020/03/27 04:45:03 - CMDPHP MAILER ERROR Backtrace: (/poller.php[801]:api_plugin_hook(), /lib/plugins.php[74]:api_plugin_run_plugin_hook(), /lib/plugins.php[177]:thold_poller_bottom(), /plugins/thold/includes/polling.php[45]:thold_check_all_thresholds(), /plugins/thold/includes/polling.php[474]:thold_check_threshold(), /plugins/thold/thold_functions.php[2920]:thold_mail(), /plugins/thold/thold_functions.php[5388]:mailer(), /lib/functions.php[3535]:record_mailer_error(), /lib/functions.php[3733]:cacti_debug_backtrace())
2020/03/27 04:45:03 - CMDPHP MAILER ERROR:
2020/03/27 04:45:03 - CMDPHP MAILER ERROR Backtrace: (/poller.php[801]:api_plugin_hook(), /lib/plugins.php[74]:api_plugin_run_plugin_hook(), /lib/plugins.php[177]:thold_poller_bottom(), /plugins/thold/includes/polling.php[45]:thold_check_all_thresholds(), /plugins/thold/includes/polling.php[474]:thold_check_threshold(), /plugins/thold/thold_functions.php[2334]:thold_mail(), /plugins/thold/thold_functions.php[5388]:mailer(), /lib/functions.php[3535]:record_mailer_error(), /lib/functions.php[3733]:cacti_debug_backtrace())
2020/03/27 04:45:03 - CMDPHP MAILER ERROR:

At present, the main body of attachment specified by the mailer function provided by cacti core is PNG itself, but the third-party library phpmailer only supports the local file path. It recognizes the PNG content as a path and directly reports an error

Screenshots
Screen Shot 2020-03-27 at 5 48 55 PM

Desktop (please complete the following information):
rhel8.2 x64
cacti 1.2.10
thold 1.3.4
FF 74

Activity

  1. ddb4github commented on Mar 27, 2020

    @ddb4github
    Contributor

    If mail body do not include both of <GRAPH> and <GRAPH:, functions.php--> mailer() will attach image object as attachement with PHPMailer-->addAttachment()
    But PHPMailer-->addAttachment() only accept Local file path as attachment source.

  2. added this to the 1.2.11 milestone on Mar 27, 2020
  3. added a commit that references this issue on Mar 27, 2020
  4. ddb4github commented on Mar 29, 2020

    @ddb4github
    Contributor

    How about this diff, then $attachment['attachment'] support both image realpath and image data..
    Before this diff:

    • mailer() will ignore attachment that is image data.
      After this diff:
    • inline mode also support read attachment from local filepath
    --- a/lib/functions.php
    +++ b/lib/functions.php
    @@ -3644,11 +3644,17 @@ function mailer($from, $to, $cc, $bcc, $replyto, $subject, $body, $body_text = '
    
                                    /* attempt to attach */
                                    if (!($graph_mode || $graph_ids)) {
    -                                       if (!empty($attachment['filename']) && file_exists($attachment['filename'])) {
    +                                       if (!empty($attachment['attachment']) && file_exists($attachment['attachment'])) {
                                                    $result = $mail->addAttachment($attachment['attachment'], $attachment['filename'], $attachment['encoding'], $attachment['mime_type'], $attachment['inline']);
    +                                       } else {
    +                                               $result = $mail->addStringAttachment($attachment['attachment'], $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']);
                                            }
                                    } else {
    -                                       $result = $mail->addStringEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']);
    +                                       if (!empty($attachment['attachment']) && file_exists($attachment['attachment'])) {
    +                                               $result = $mail->addEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['encoding'], $attachment['mime_type'], $attachment['inline']);
    +                                       } else {
    +                                               $result = $mail->addStringEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']);
    +                                       }
                                    }
    
                                    if ($result == false) {
    
  5. TheWitness commented on Mar 29, 2020

    @TheWitness
    Member

    It tried and received a number of back trace errors. Also, your theme pull request was reverted due to not working.

  6. ddb4github commented on Mar 29, 2020

    @ddb4github
    Contributor
    $result = $mail->addEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['encoding'], $attachment['mime_type'], $attachment['inline']);

    should be

    $result = $mail->addEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], $attachment['encoding'], $attachment['mime_type'], $attachment['inline']);
  7. TheWitness commented on Mar 29, 2020

    @TheWitness
    Member

    Just when I thought I could go for a walk.

  8. ddb4github commented on Mar 29, 2020

    @ddb4github
    Contributor

    Need to upgrade PHPMailer.
    Before 6.1.0, function addStringAttachment does not return any true/false

  9. netniV commented on Apr 1, 2020

    @netniV
    Member

    If we have updated PHPMailer and that becomes a minimum requirement, packagers such as @paulgevers and @mortenstevens will need to add that to the requirements of their packages.

  10. netniV commented on Apr 5, 2020

    @netniV
    Member

    OK, I'm confused as both the commits listed in this issue are showing up as DEVELOP commits, yet appear it's @ddb4github's change that appears in the 1.2.x branch.

  11. locked and limited conversation to collaborators on Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions