Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Enviroment variables and how to use mail

    LAMP
    3
    9
    538
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • subven
      subven last edited by subven

      First off: Is the documentation for Email in LAMP still valid? It says exposed variables look like MAIL_SMTP_SERVER but it seems all Cloudron enviroment variables within the LAMP app start with CLOUDRON_

      root@a47d817b-fd94-42e1-9a01-4986c9952996:/app/data/public/config# printenv | grep MAIL_SMTP_SERVER
      CLOUDRON_MAIL_SMTP_SERVER=mail
      

      So I assume the correct way to use these variables is:

      getenv('CLOUDRON_MAIL_SMTP_SERVER')
      

      Second:

      I want to use the phpmailer addon for a Friendica instance. This addon replaces the mail() function with the PHPMailer library. The addon is configured and activated within the application but it still seems to look out for sendmail.

      www-data@900e2935-6f37-42bc-8609-86876b5a2105:~/public/addon/phpmailer$ composer show -i
      phpmailer/phpmailer v6.2.0 PHPMailer is a full-featured email creation and transfer class for PHP
      

      LAMP log

      sh: 1: /usr/sbin/sendmail: not found
      sh: 1: /usr/sbin/sendmail: not found
      

      Application log:

      index [ERROR]: PHPMailer error {"email":{"fromName":"\"der Administrator von Friendica Social Network\"","fromAddress":"REMOVED","replyTo":"REMOVED","toAddress":"REMOVED","subject":"ttes","msgHtml":"teswdfrsdf","msgText":"teswdfrsdf","additionalMailHeader":[],"toUid":null},"ErrorInfo":"Could not instantiate mail function.","exception":{}} - {"file":"phpmailer.php","line":108,"function":"phpmailer_emailer_send_prepare","uid":"f4936f","process_id":26}
      

      I also tried to use real (plain text) SMTP credentials with the same result 😞 The relevant part of my addon.config.php looks like this:

      'phpmailer' => [
          // smtp (Boolean)
          // Enables SMTP relaying for outbound emails
          'smtp' => true,
      
          // smtp_server (String)
          // SMTP server host name
          'smtp_server' => getenv('CLOUDRON_MAIL_SMTP_SERVER'),
      
          // smtp_port (Integer)
          // SMTP server port number
          'smtp_port' => getenv('CLOUDRON_MAIL_SMTP_PORT'),
      
          // smtp_secure (String)
          // What kind of encryption to use on the SMTP connection.
          // Options: '', 'ssl' or 'tls'.
          'smtp_secure' => '',
      
          // smtp_port_s (Integer)
          // Secure SMTP server port number
          'smtp_port_s' => getenv('CLOUDRON_MAIL_SMTPS_PORT'),
      
          // smtp_username (String)
          // SMTP server authentication user name
          // Empty string disables authentication
          'smtp_username' => getenv('CLOUDRON_MAIL_SMTP_USERNAME'),
      
          // smtp_password (String)
          // SMTP server authentication password
          // Empty string disables authentication
          'smtp_password' => getenv('CLOUDRON_MAIL_SMTP_PASSWORD'),
      
          // smtp_from (String)
          // From address used when using the SMTP server
          // Example: no-reply@example.com
          'smtp_from' => getenv('CLOUDRON_MAIL_FROM'),
      ],
      
      girish 1 Reply Last reply Reply Quote 0
      • girish
        girish Staff @subven last edited by

        @subven said in Enviroment variables and how to use mail:

        'smtp_port_s' => getenv('CLOUDRON_MAIL_SMTPS_PORT'),
        

        This should be removed. Otherwise, your settings look correct. I will fix the docs to have the correct env vars. It seems that it is still looking for sendmail somewhere instead of using SMTP.

        1 Reply Last reply Reply Quote 0
        • subven
          subven last edited by

          True that 😞 It seems like I have to give up here and host it elsewhere which is sad because they also have a Docker container.

          girish 2 Replies Last reply Reply Quote 0
          • girish
            girish Staff @subven last edited by

            @subven Is there possibly a setting in friendica to make it use phpmailer instead of sendmail (since phpmailer seems to be an addon)?

            subven 1 Reply Last reply Reply Quote 0
            • girish
              girish Staff @subven last edited by girish

              @subven Actually, it's easy to just put an error_log in https://github.com/friendica/friendica-addons/blob/develop/phpmailer/phpmailer.php#L35 and see if the function is getting called at all?

              edit: don't mind me, clearly the error message you initially posted is from https://github.com/friendica/friendica-addons/blob/develop/phpmailer/phpmailer.php#L108 .

              1 Reply Last reply Reply Quote 0
              • subven
                subven @girish last edited by subven

                @girish not in the UI or config. The addon needs to be installed and activated thats it. I think I saw them using hooks to distinguish between the sendmail and phpmailer.

                EDIT:

                What I noticed: There is an issue with the from address. All my testmails seem to come from noreply@friendica.herewasmydomain.com instead of noreply@herewasmydomain.com. They fixed this with adding $SMTP_DOMAIN in their Docker repo. Fixing the wrong mail address for the (internal and hidden) system account in the database changed nothing.

                @girish thank you for digging into that but please do not waste too much time because this might be a rare use case and not really Cloudrons fault.

                girish 1 Reply Last reply Reply Quote 0
                • girish
                  girish Staff @subven last edited by

                  @subven As per https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#could-not-instantiate-mail-function, if we use isSMTP which the addon uses, it should use SMTP directly. I will maybe give it a shot later today to understand why it's not sending mail.

                  P 1 Reply Last reply Reply Quote 0
                  • P
                    peterle @girish last edited by

                    @girish
                    you see any chance that friendica becomes a cloudron App?

                    girish 1 Reply Last reply Reply Quote 0
                    • girish
                      girish Staff @peterle last edited by

                      @peterle Yes, sure. We need to bring up the package at https://github.com/M-arcus/friendica-docker-image up to speed. It was packaged 3 years ago, so it probably won't work now.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB