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: 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?