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

    Solved PHP mail() function fails

    Support
    3
    9
    1157
    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.
    • M-arcus
      M-arcus last edited by

      I have an php app installed inside a cloudron docker container, which uses the mail() function.

      Do i need to add configuration?

      1 Reply Last reply Reply Quote 0
      • M-arcus
        M-arcus last edited by

        Error message: postdrop: warning: mail_queue_enter: create file maildrop/186514.150: Read-onlyfile system

        1 Reply Last reply Reply Quote 0
        • fbartels
          fbartels App Dev last edited by

          Hi @M-arcus ,

          I've stumbled upon similar things in the past. While the cloudron base image already does bring postfix, but due to the nature that most of the container is read-only it does not properly work. I've tried remapping all its folders but due to time constraints did not succeed.

          The solution to your problem is imho to configure php to use the cloudron mailserver for sending out mails. e.g. https://www.quackit.com/php/tutorial/php_mail_configuration.cfm

          M-arcus 1 Reply Last reply Reply Quote 0
          • M-arcus
            M-arcus @fbartels last edited by

            @fbartels Thanks you, I will try that

            I am using the LAMP-Cloudron-Container as base.

            Do you have a container on git.cloudron.io, where you did such configuration?

            fbartels 1 Reply Last reply Reply Quote 0
            • fbartels
              fbartels App Dev @M-arcus last edited by

              @m-arcus said in PHP mail() function fails:

              I am using the LAMP-Cloudron-Container as base.

              here I was not quite sure if you're really talking about an own app. If you are indeed making an own app it may be easier to install and configure something like ssmtpd.

              If you still want to look into the postfix configuration my attempts were at https://git.cloudron.io/cloudron/kopano-app/tree/postfix-test

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

                @M-arcus Apps on Cloudron must use SMTP to send mail. To get the SMTP credentials you can use the following environment variables - docs:

                MAIL_SMTP_SERVER= # the mail server (relay) that apps can use. this can be an IP or DNS name
                MAIL_SMTP_PORT= # the mail server port. Currently, this port disables TLS and STARTTLS.
                MAIL_SMTPS_PORT= # SMTPS server port.
                MAIL_SMTP_USERNAME= # the username to use for authentication
                MAIL_SMTP_PASSWORD= # the password to use for authentication
                MAIL_FROM= # the "From" address to use
                MAIL_DOMAIN= # the domain name to use for email sending (i.e username@domain)

                I am not a PHP developer but most of our apps use PHPmailer or the Pear mail package to send email via SMTP.

                As for the error itself, this is because the PHP mail() function is configured to use the binary listed in sendmail_path in php.ini which is postfix/sendmail. Since Cloudron runs apps on a read-only file system, queuing it in the filesystem won't work. Even if it did work, there is nobody to send the emails from the filesystem...

                M-arcus 1 Reply Last reply Reply Quote 0
                • M-arcus
                  M-arcus @girish last edited by

                  @girish Thank you for the explanation.

                  So you're saying sendmail is not going to work, right?

                  The problem is now that the application i'm installing depends on mail().
                  I'm going have to file a merge Request or build an addon for the PHP Mailer replacement.

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

                    That's correct, sendmail is not going to work.

                    1 Reply Last reply Reply Quote 1
                    • M-arcus
                      M-arcus last edited by

                      @fbartels @girish Thank you for the support.

                      Solution:

                      • use a SMTP mail solution
                      • sendmail (and the mail()) are not usable in current state
                      • PHPMailer could be used as an alternative
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB