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. Lamp mail don't work

Lamp mail don't work

Scheduled Pinned Locked Moved LAMP
6 Posts 3 Posters 825 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.
  • CaranougaC Offline
    CaranougaC Offline
    Caranouga
    wrote on last edited by
    #1

    Hello everyone, here is my problem:

    I have a friend who has installed Cloudron on his server, and as I needed something to put my site I asked him if it does not bother him to put me an application (LAMP). He proposed me to create a mailbox with roundcube (caranouga@caradev.ml) except that the problem is that the mail function of cloudron does not work!:

    function cloudronmail($to, $subject, $body, $headers)
    {
        $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
    
        $B = 8192;
        $c = "\r\n";
        $s = getenv('CLOUDRON_MAIL_FROM');
    
        fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
            $junk = fgets($smtp, $B);
    
        // Envelope
        fwrite($smtp, 'mail from: ' . $s . $c);
            $junk = fgets($smtp, $B);
        fwrite($smtp, 'rcpt to: ' . $to . $c);
            $junk = fgets($smtp, $B);
        fwrite($smtp, 'data' . $c);
    
            $junk = fgets($smtp, $B);
    
        // Header
        fwrite($smtp, 'To: ' . $to . $c);
        if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
        if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
        fwrite($smtp, $headers . $c);
    
        // Body
        if(strlen($body)) fwrite($smtp, $body . $c);
        fwrite($smtp, $c . '.' . $c);
            $junk = fgets($smtp, $B);
    
        // Close
        fwrite($smtp, 'quit' . $c);
            $junk = fgets($smtp, $B);
        fclose($smtp);
    }
    

    Here is what I put:

    <?php
    function cloudronmail($to, $subject, $body, $headers)
    {
        $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
    
        $B = 8192;
        $c = "\r\n";
        $s = getenv('CLOUDRON_MAIL_FROM');
    
        fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
            $junk = fgets($smtp, $B);
    
        // Envelope
        fwrite($smtp, 'mail from: ' . $s . $c);
            $junk = fgets($smtp, $B);
        fwrite($smtp, 'rcpt to: ' . $to . $c);
            $junk = fgets($smtp, $B);
        fwrite($smtp, 'data' . $c);
    
            $junk = fgets($smtp, $B);
    
        // Header
        fwrite($smtp, 'To: ' . $to . $c);
        if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
        if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
        fwrite($smtp, $headers . $c);
    
        // Body
        if(strlen($body)) fwrite($smtp, $body . $c);
        fwrite($smtp, $c . '.' . $c);
            $junk = fgets($smtp, $B);
    
        // Close
        fwrite($smtp, 'quit' . $c);
            $junk = fgets($smtp, $B);
        fclose($smtp);
    }
    
      $headerss = 'From: caranouga@caradev.ml' . "\r\n" .
      'Reply-To: m*********t@gmail.com' . "\r\n" .
      'X-Mailer: PHP/' . phpversion();
    
    cloudronmail("m*********t@gmail.com", "Test", "Test", $headerss);
    echo 'test';
    echo '
    ';
    
    echo getenv('CLOUDRON_MAIL_SMTP_SERVER');
    echo '
    ';
    echo getenv('CLOUDRON_MAIL_SMTP_PORT');
    echo '
    ';
    getenv('CLOUDRON_MAIL_SMTPS_PORT');
    echo '
    ';
    echo getenv('CLOUDRON_MAIL_SMTP_USERNAME');
    echo '
    ';
    echo getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
    echo '
    ';
    echo getenv('CLOUDRON_MAIL_FROM');
    echo '
    ';
    echo getenv('CLOUDRON_MAIL_DOMAIN');
    echo '
    ';
    getenv('HOSTNAME');
    

    and a screen of what it gives: 785b6b2f-076b-4ec3-87db-69284c3ccc27-image.png I would like to know if it is a problem with the cloudron or if I did something wrong

    Thanks in advance for your help,

    Caranouga

    PS: The url of the roundcube is mail.miningheberg.ml, here is a screen of my creditentials.txt file:

    Do not edit this file. It will be overwritten on any update or app restart and is autogenerated.
    
    Sendmail Credentials
    ====================
    
                       PHP usage                               Value
    Hostname:   getenv('CLOUDRON_MAIL_SMTP_SERVER')      mail
    Port:       getenv('CLOUDRON_MAIL_SMTP_PORT')        2525
    TLS Port:   getenv('CLOUDRON_MAIL_SMTPS_PORT')       2465
    Username:   getenv('CLOUDRON_MAIL_SMTP_USERNAME')    caranouga@caradev.ml
    Password:   getenv('CLOUDRON_MAIL_SMTP_PASSWORD')    the_password
    Address:    getenv('CLOUDRON_MAIL_FROM')             caranouga@caradev.ml
    Domain:     getenv('CLOUDRON_MAIL_DOMAIN')           caradev.ml
    
    
    
    
    
    

    I changed my roundcube password to match the password of the creditentials file, but it does not work.
    PS2: I have a last question I look at you I find variables that are not defined: $eno, $estr, etc... Is this normal?

    nebulonN girishG 2 Replies Last reply
    0
    • CaranougaC Caranouga

      Hello everyone, here is my problem:

      I have a friend who has installed Cloudron on his server, and as I needed something to put my site I asked him if it does not bother him to put me an application (LAMP). He proposed me to create a mailbox with roundcube (caranouga@caradev.ml) except that the problem is that the mail function of cloudron does not work!:

      function cloudronmail($to, $subject, $body, $headers)
      {
          $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
      
          $B = 8192;
          $c = "\r\n";
          $s = getenv('CLOUDRON_MAIL_FROM');
      
          fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
              $junk = fgets($smtp, $B);
      
          // Envelope
          fwrite($smtp, 'mail from: ' . $s . $c);
              $junk = fgets($smtp, $B);
          fwrite($smtp, 'rcpt to: ' . $to . $c);
              $junk = fgets($smtp, $B);
          fwrite($smtp, 'data' . $c);
      
              $junk = fgets($smtp, $B);
      
          // Header
          fwrite($smtp, 'To: ' . $to . $c);
          if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
          if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
          fwrite($smtp, $headers . $c);
      
          // Body
          if(strlen($body)) fwrite($smtp, $body . $c);
          fwrite($smtp, $c . '.' . $c);
              $junk = fgets($smtp, $B);
      
          // Close
          fwrite($smtp, 'quit' . $c);
              $junk = fgets($smtp, $B);
          fclose($smtp);
      }
      

      Here is what I put:

      <?php
      function cloudronmail($to, $subject, $body, $headers)
      {
          $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
      
          $B = 8192;
          $c = "\r\n";
          $s = getenv('CLOUDRON_MAIL_FROM');
      
          fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
              $junk = fgets($smtp, $B);
      
          // Envelope
          fwrite($smtp, 'mail from: ' . $s . $c);
              $junk = fgets($smtp, $B);
          fwrite($smtp, 'rcpt to: ' . $to . $c);
              $junk = fgets($smtp, $B);
          fwrite($smtp, 'data' . $c);
      
              $junk = fgets($smtp, $B);
      
          // Header
          fwrite($smtp, 'To: ' . $to . $c);
          if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
          if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
          fwrite($smtp, $headers . $c);
      
          // Body
          if(strlen($body)) fwrite($smtp, $body . $c);
          fwrite($smtp, $c . '.' . $c);
              $junk = fgets($smtp, $B);
      
          // Close
          fwrite($smtp, 'quit' . $c);
              $junk = fgets($smtp, $B);
          fclose($smtp);
      }
      
        $headerss = 'From: caranouga@caradev.ml' . "\r\n" .
        'Reply-To: m*********t@gmail.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
      
      cloudronmail("m*********t@gmail.com", "Test", "Test", $headerss);
      echo 'test';
      echo '
      ';
      
      echo getenv('CLOUDRON_MAIL_SMTP_SERVER');
      echo '
      ';
      echo getenv('CLOUDRON_MAIL_SMTP_PORT');
      echo '
      ';
      getenv('CLOUDRON_MAIL_SMTPS_PORT');
      echo '
      ';
      echo getenv('CLOUDRON_MAIL_SMTP_USERNAME');
      echo '
      ';
      echo getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
      echo '
      ';
      echo getenv('CLOUDRON_MAIL_FROM');
      echo '
      ';
      echo getenv('CLOUDRON_MAIL_DOMAIN');
      echo '
      ';
      getenv('HOSTNAME');
      

      and a screen of what it gives: 785b6b2f-076b-4ec3-87db-69284c3ccc27-image.png I would like to know if it is a problem with the cloudron or if I did something wrong

      Thanks in advance for your help,

      Caranouga

      PS: The url of the roundcube is mail.miningheberg.ml, here is a screen of my creditentials.txt file:

      Do not edit this file. It will be overwritten on any update or app restart and is autogenerated.
      
      Sendmail Credentials
      ====================
      
                         PHP usage                               Value
      Hostname:   getenv('CLOUDRON_MAIL_SMTP_SERVER')      mail
      Port:       getenv('CLOUDRON_MAIL_SMTP_PORT')        2525
      TLS Port:   getenv('CLOUDRON_MAIL_SMTPS_PORT')       2465
      Username:   getenv('CLOUDRON_MAIL_SMTP_USERNAME')    caranouga@caradev.ml
      Password:   getenv('CLOUDRON_MAIL_SMTP_PASSWORD')    the_password
      Address:    getenv('CLOUDRON_MAIL_FROM')             caranouga@caradev.ml
      Domain:     getenv('CLOUDRON_MAIL_DOMAIN')           caradev.ml
      
      
      
      
      
      

      I changed my roundcube password to match the password of the creditentials file, but it does not work.
      PS2: I have a last question I look at you I find variables that are not defined: $eno, $estr, etc... Is this normal?

      nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #2

      @caranouga hi there. I am not quite sure what this has to do with roundcube as such. I assume in your case you have to create a mailbox via the Cloudron dashboard and then make sure that LAMP instance is configured to use that as the mail sending identity.

      Further do you have any error message which allow to dig into this deeper?

      CaranougaC 1 Reply Last reply
      0
      • nebulonN nebulon

        @caranouga hi there. I am not quite sure what this has to do with roundcube as such. I assume in your case you have to create a mailbox via the Cloudron dashboard and then make sure that LAMP instance is configured to use that as the mail sending identity.

        Further do you have any error message which allow to dig into this deeper?

        CaranougaC Offline
        CaranougaC Offline
        Caranouga
        wrote on last edited by
        #3

        @nebulon Hello, thank you for your answer.

        I already changed the LAMP email, and there is indeed a caranouga@caradev.ml mailbox.

        I think I have an idea:

        I just went back to the creditentials.txt file, and I saw that there is a getenv('CLOUDRON_MAIL_DOMAIN') variable that gives caradev.ml, maybe the mail function is using this domain to send emails instead of using miningheberg.ml.

        Thanks to you,
        Caranouga

        PS: I don't have an administrator account so I can't see the lamp and cloudron settings, so I have to wait for my friend to show me.

        girishG 1 Reply Last reply
        0
        • girishG girish moved this topic from Support on
        • CaranougaC Caranouga

          @nebulon Hello, thank you for your answer.

          I already changed the LAMP email, and there is indeed a caranouga@caradev.ml mailbox.

          I think I have an idea:

          I just went back to the creditentials.txt file, and I saw that there is a getenv('CLOUDRON_MAIL_DOMAIN') variable that gives caradev.ml, maybe the mail function is using this domain to send emails instead of using miningheberg.ml.

          Thanks to you,
          Caranouga

          PS: I don't have an administrator account so I can't see the lamp and cloudron settings, so I have to wait for my friend to show me.

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

          @caranouga Did you figure this out? What is the error you are facing?

          1 Reply Last reply
          0
          • CaranougaC Caranouga

            Hello everyone, here is my problem:

            I have a friend who has installed Cloudron on his server, and as I needed something to put my site I asked him if it does not bother him to put me an application (LAMP). He proposed me to create a mailbox with roundcube (caranouga@caradev.ml) except that the problem is that the mail function of cloudron does not work!:

            function cloudronmail($to, $subject, $body, $headers)
            {
                $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
            
                $B = 8192;
                $c = "\r\n";
                $s = getenv('CLOUDRON_MAIL_FROM');
            
                fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
                    $junk = fgets($smtp, $B);
            
                // Envelope
                fwrite($smtp, 'mail from: ' . $s . $c);
                    $junk = fgets($smtp, $B);
                fwrite($smtp, 'rcpt to: ' . $to . $c);
                    $junk = fgets($smtp, $B);
                fwrite($smtp, 'data' . $c);
            
                    $junk = fgets($smtp, $B);
            
                // Header
                fwrite($smtp, 'To: ' . $to . $c);
                if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
                if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
                fwrite($smtp, $headers . $c);
            
                // Body
                if(strlen($body)) fwrite($smtp, $body . $c);
                fwrite($smtp, $c . '.' . $c);
                    $junk = fgets($smtp, $B);
            
                // Close
                fwrite($smtp, 'quit' . $c);
                    $junk = fgets($smtp, $B);
                fclose($smtp);
            }
            

            Here is what I put:

            <?php
            function cloudronmail($to, $subject, $body, $headers)
            {
                $smtp = stream_socket_client('tcp://' . getenv('CLOUDRON_MAIL_SMTP_SERVER') . ':' . getenv('CLOUDRON_MAIL_SMTP_PORT'), $eno, $estr, 30);
            
                $B = 8192;
                $c = "\r\n";
                $s = getenv('CLOUDRON_MAIL_FROM');
            
                fwrite($smtp, 'helo ' . getenv('HOSTNAME') . $c);
                    $junk = fgets($smtp, $B);
            
                // Envelope
                fwrite($smtp, 'mail from: ' . $s . $c);
                    $junk = fgets($smtp, $B);
                fwrite($smtp, 'rcpt to: ' . $to . $c);
                    $junk = fgets($smtp, $B);
                fwrite($smtp, 'data' . $c);
            
                    $junk = fgets($smtp, $B);
            
                // Header
                fwrite($smtp, 'To: ' . $to . $c);
                if(strlen($subject)) fwrite($smtp, 'Subject: ' . $subject . $c);
                if(strlen($headers)) fwrite($smtp, $headers); // Must be \r\n (delimited)
                fwrite($smtp, $headers . $c);
            
                // Body
                if(strlen($body)) fwrite($smtp, $body . $c);
                fwrite($smtp, $c . '.' . $c);
                    $junk = fgets($smtp, $B);
            
                // Close
                fwrite($smtp, 'quit' . $c);
                    $junk = fgets($smtp, $B);
                fclose($smtp);
            }
            
              $headerss = 'From: caranouga@caradev.ml' . "\r\n" .
              'Reply-To: m*********t@gmail.com' . "\r\n" .
              'X-Mailer: PHP/' . phpversion();
            
            cloudronmail("m*********t@gmail.com", "Test", "Test", $headerss);
            echo 'test';
            echo '
            ';
            
            echo getenv('CLOUDRON_MAIL_SMTP_SERVER');
            echo '
            ';
            echo getenv('CLOUDRON_MAIL_SMTP_PORT');
            echo '
            ';
            getenv('CLOUDRON_MAIL_SMTPS_PORT');
            echo '
            ';
            echo getenv('CLOUDRON_MAIL_SMTP_USERNAME');
            echo '
            ';
            echo getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
            echo '
            ';
            echo getenv('CLOUDRON_MAIL_FROM');
            echo '
            ';
            echo getenv('CLOUDRON_MAIL_DOMAIN');
            echo '
            ';
            getenv('HOSTNAME');
            

            and a screen of what it gives: 785b6b2f-076b-4ec3-87db-69284c3ccc27-image.png I would like to know if it is a problem with the cloudron or if I did something wrong

            Thanks in advance for your help,

            Caranouga

            PS: The url of the roundcube is mail.miningheberg.ml, here is a screen of my creditentials.txt file:

            Do not edit this file. It will be overwritten on any update or app restart and is autogenerated.
            
            Sendmail Credentials
            ====================
            
                               PHP usage                               Value
            Hostname:   getenv('CLOUDRON_MAIL_SMTP_SERVER')      mail
            Port:       getenv('CLOUDRON_MAIL_SMTP_PORT')        2525
            TLS Port:   getenv('CLOUDRON_MAIL_SMTPS_PORT')       2465
            Username:   getenv('CLOUDRON_MAIL_SMTP_USERNAME')    caranouga@caradev.ml
            Password:   getenv('CLOUDRON_MAIL_SMTP_PASSWORD')    the_password
            Address:    getenv('CLOUDRON_MAIL_FROM')             caranouga@caradev.ml
            Domain:     getenv('CLOUDRON_MAIL_DOMAIN')           caradev.ml
            
            
            
            
            
            

            I changed my roundcube password to match the password of the creditentials file, but it does not work.
            PS2: I have a last question I look at you I find variables that are not defined: $eno, $estr, etc... Is this normal?

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

            @caranouga said in Lamp mail don't work:

            PS2: I have a last question I look at you I find variables that are not defined: $eno, $estr, etc... Is this normal?

            What is $eno and $estr ?

            1 Reply Last reply
            0
            • girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by
              #6

              I was able to send mails with PHPMailer.

              <?php
              
              use PHPMailer\PHPMailer\PHPMailer;
              use PHPMailer\PHPMailer\Exception;
              
              require 'vendor/autoload.php';
              
              $sender = getenv('CLOUDRON_MAIL_FROM');
              $senderName = 'LAMP Test Email';
              $recipient = 'test@cloudron.io';
              $usernameSmtp = getenv('CLOUDRON_MAIL_SMTP_USERNAME');
              $passwordSmtp = getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
              $host = getenv('CLOUDRON_MAIL_SMTP_SERVER');
              $port = (int) getenv('CLOUDRON_MAIL_SMTP_PORT');
              $subject = 'Cloudron test (SMTP interface accessed using PHP)';
              $bodyText =  "Email Test\r\nThis email was sent through the
                  Cloudron SMTP interface using the PHPMailer class.";
              $bodyHtml = '<h1>Email Test</h1>';
              
              $mail = new PHPMailer(true);
              
              try {
                  $mail->isSMTP();
                  $mail->setFrom($sender, $senderName);
                  $mail->Username   = $usernameSmtp;
                  $mail->Password   = $passwordSmtp;
                  $mail->Host       = $host;
                  $mail->Port       = $port;
                  $mail->SMTPAuth   = true;
              
                  $mail->addAddress($recipient);
              
                  $mail->isHTML(true);
                  $mail->Subject    = $subject;
                  $mail->Body       = $bodyHtml;
                  $mail->AltBody    = $bodyText;
                  $mail->Send();
                  echo "Email sent!" , PHP_EOL;
              } catch (phpmailerException $e) {
                  echo "An error occurred. {$e->errorMessage()}", PHP_EOL; //Catch errors from PHPMailer.
              } catch (Exception $e) {
                  echo "Email not sent. {$mail->ErrorInfo}", PHP_EOL;
              }
              
              ?>
              
              

              (Adapted from https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html )

              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