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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. LAMP
  3. Enviroment variables and how to use mail

Enviroment variables and how to use mail

Scheduled Pinned Locked Moved LAMP
9 Posts 3 Posters 1.8k Views 3 Watching
  • 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.
    • subvenS Offline
      subvenS Offline
      subven
      wrote on last edited by subven
      #1

      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'),
      ],
      
      girishG 1 Reply Last reply
      0
      • subvenS 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'),
        ],
        
        girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #2

        @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
        0
        • subvenS Offline
          subvenS Offline
          subven
          wrote on last edited by
          #3

          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.

          girishG 2 Replies Last reply
          0
          • subvenS subven

            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.

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #4

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

            subvenS 1 Reply Last reply
            0
            • subvenS subven

              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.

              girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by girish
              #5

              @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
              0
              • girishG girish

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

                subvenS Offline
                subvenS Offline
                subven
                wrote on last edited by subven
                #6

                @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.

                girishG 1 Reply Last reply
                0
                • subvenS 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.

                  girishG Offline
                  girishG Offline
                  girish
                  Staff
                  wrote on last edited by
                  #7

                  @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
                  0
                  • girishG girish

                    @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 Offline
                    P Offline
                    peterle
                    wrote on last edited by
                    #8

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

                    girishG 1 Reply Last reply
                    0
                    • P peterle

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

                      girishG Offline
                      girishG Offline
                      girish
                      Staff
                      wrote on last edited by
                      #9

                      @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
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Bookmarks
                        • Search