1

Topic: How to enable smtp

==== Required information ====
- iRedMail version 0.9.5-1
- Linux/BSD distribution name and version: Centos 6.6
- Store mail accounts in which backend MySQL
- Web server Apache
- Manage mail accounts with iRedAdmin-Pro? No
- Related log if you're reporting an issue:
====

Hello

i have just installed iredmail last week and everything works like a charm

i was wondering how can i enable smtp to use it with 3rd party apps outside of the roundcube webmail

i also have one off-topic question : is iredmail based on postfix ? meaning that everything that work on postfix tutorials should work with iredmail ?

thank you

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: How to enable smtp

kinneyscott5 wrote:

i was wondering how can i enable smtp to use it with 3rd party apps outside of the roundcube webmail

If your third-party apps supports TLS, please use port 587 with STARTTLS (some apps call it TLS) encryption. If not, try this tutorial:
http://www.iredmail.org/docs/additional.smtp.port.html

kinneyscott5 wrote:

i also have one off-topic question : is iredmail based on postfix ? meaning that everything that work on postfix tutorials should work with iredmail ?

iRedMail uses Postfix as MTA.

Most tutorials should work, but sometimes one setting/parameter relies on another setting/parameter, so you still need to understand how current Postfix (configured by iRedMail) works first.

3

Re: How to enable smtp

Hello

My 3rd app support TLS, but i'm not sure if the smtp is configured by default to be used with 3rd party apps, since you didn't mention any changes regarding TLS,  does this mean that i don't need to change anything?

Also how can i get my smtp authentication (host,  user & pass)

I'm sorry if i ask too many questions this is my first time installing an smtp on a vps

4

Re: How to enable smtp

iRedMail supports SMTP (port 25), SMTP over TLS (port 587) by default.

5

Re: How to enable smtp

Okey but how can i get my login info (hostname,  user and pss)
Should i use my server hostname and the user and password that i use to login on the webmail?

6

Re: How to enable smtp

kinneyscott5 wrote:

Should i use my server hostname and the user and password that i use to login on the webmail?

Yes. And your server hostname must be resolvable by DN query.

7

Re: How to enable smtp

Hello

i'm trying to use PHPMailer (https://github.com/PHPMailer/PHPMailer) but i'm not sure what i'm doing wrong

$mail->Host = ""; i'm using my server hostname here
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "";i'm using my email here , the one that i use to login to roundcube
$mail->Password = "";i'm using the above email's password
but i'm getting an error :
Mailer Error for email: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/ … leshooting

8

Re: How to enable smtp

kinneyscott5 wrote:

Mailer Error for email: SMTP connect() failed.

Try IP address of your mail server.

9 (edited by kinneyscott5 2016-11-02 09:46:01)

Re: How to enable smtp

Hello

i've tried the ip and it failed to connect as well

this is the log of phpmailer

SERVER -> CLIENT: 220 server1.benachzone.com ESMTP Postfix
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-server1.benachzone.com250-PIPELINING250-SIZE 15728640250-ETRN250-STARTTLS250-ENHANCEDSTATUSCODES250-8BITMIME250 DSN
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 Bye
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/ … leshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/ … leshooting

this is how my phpmailer script look like :

<?php
/**
* This example shows making an SMTP connection with authentication.
*/

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "173.212.198.117";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "*************"; //the email i use to login at roundcube , the one i created and not the postmaster one
//Password to use for SMTP authentication
$mail->Password = "**************"; password for the email above
//Set who the message is to be sent from
$mail->setFrom('*****************', 'Kinney');
//Set an alternative reply-to address
//Set who the message is to be sent to
$mail->addAddress('web-e5si2K@mail-tester.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

ps : i'm trying the phpmailer from wampserver from my computer

thanks

10

Re: How to enable smtp

Any related error/warning in Postfix log file (/var/log/maillog) on iRedMail server?

11

Re: How to enable smtp

this is what i got from the file you pointed out

Oct 30 05:00:53 server1 amavis[21782]: starting. /usr/sbin/amavisd at server1.benachzone.com amavisd-new-2.9.1 (20140627), Unicode aware, LANG="en_US.UTF-8"
Oct 30 05:00:54 server1 amavis[21784]: Net::Server: Group Not Defined.  Defaulting to EGID '497 497'
Oct 30 05:00:54 server1 amavis[21784]: Net::Server: User Not Defined.  Defaulting to EUID '496'
Oct 30 05:00:54 server1 amavis[21784]: Module Amavis::Conf        2.321
Oct 30 05:00:54 server1 amavis[21784]: Module Archive::Zip        1.30
Oct 30 05:00:54 server1 amavis[21784]: Module BerkeleyDB          0.43
Oct 30 05:00:54 server1 amavis[21784]: Module Compress::Raw::Zlib 2.021
Oct 30 05:00:54 server1 amavis[21784]: Module Compress::Zlib      2.021
Oct 30 05:00:54 server1 amavis[21784]: Module Crypt::OpenSSL::RSA 0.25
Oct 30 05:00:54 server1 amavis[21784]: Module DBD::mysql          4.013
Oct 30 05:00:54 server1 amavis[21784]: Module DBI                 1.609
Oct 30 05:00:54 server1 amavis[21784]: Module DB_File             1.82
Oct 30 05:00:54 server1 amavis[21784]: Module Digest::MD5         2.39
Oct 30 05:00:54 server1 amavis[21784]: Module Digest::SHA         5.47
Oct 30 05:00:54 server1 amavis[21784]: Module Encode              2.35
Oct 30 05:00:54 server1 amavis[21784]: Module File::Temp          0.22
Oct 30 05:00:54 server1 amavis[21784]: Module IO::Socket::INET6   2.56
Oct 30 05:00:54 server1 amavis[21784]: Module MIME::Entity        5.427
Oct 30 05:00:54 server1 amavis[21784]: Module MIME::Parser        5.427
Oct 30 05:00:54 server1 amavis[21784]: Module MIME::Tools         5.427
"/var/log/maillog" 653L, 64819C

12

Re: How to enable smtp

update to the situation

i've added

$mail->SMTPSecure = "tls";

to my script and got an error saying that Openssl is missing
i did some research and found out that i should edit the php.ini file , i did so and enabled openssl and that problem is solved

now the issue is

SERVER -> CLIENT: 220 server1.benachzone.com ESMTP Postfix
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-server1.benachzone.com250-PIPELINING250-SIZE 15728640250-ETRN250-STARTTLS250-ENHANCEDSTATUSCODES250-8BITMIME250 DSN
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS

( ! ) Warning: stream_socket_enable_crypto(): SSL: An existing connection was forcibly closed by the remote host. in C:\wamp\www\PHPMailer-master\class.smtp.php on line 358
Call Stack
#    Time    Memory    Function    Location
1    0.0015    133792    {main}( )    ...\smtp.php:0
2    0.0147    635136    PHPMailer->send( )    ...\smtp.php:50
3    0.0176    652960    PHPMailer->postSend( )    ...\class.phpmailer.php:1206
4    0.0176    653312    PHPMailer->smtpSend( )    ...\class.phpmailer.php:1326
5    0.0176    653904    PHPMailer->smtpConnect( )    ...\class.phpmailer.php:1489
6    0.2642    792400    SMTP->startTLS( )    ...\class.phpmailer.php:1626
7    0.3501    792568    stream_socket_enable_crypto ( )    ...\class.smtp.php:358
SMTP Error: Could not connect to SMTP host.
CLIENT -> SERVER: QUIT

( ! ) Notice: fwrite(): send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in C:\wamp\www\PHPMailer-master\class.smtp.php on line 981
Call Stack
#    Time    Memory    Function    Location
1    0.0015    133792    {main}( )    ...\smtp.php:0
2    0.0147    635136    PHPMailer->send( )    ...\smtp.php:50
3    0.0176    652960    PHPMailer->postSend( )    ...\class.phpmailer.php:1206
4    0.0176    653312    PHPMailer->smtpSend( )    ...\class.phpmailer.php:1326
5    0.0176    653904    PHPMailer->smtpConnect( )    ...\class.phpmailer.php:1489
6    0.4932    815008    SMTP->quit( )    ...\class.phpmailer.php:1649
7    0.4932    815168    SMTP->sendCommand( )    ...\class.smtp.php:817
8    0.4932    815216    SMTP->client_send( )    ...\class.smtp.php:875
9    0.4933    815248    fwrite ( )    ...\class.smtp.php:981
SERVER -> CLIENT:
SMTP ERROR: QUIT command failed:
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/ … leshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/ … leshooting

13

Re: How to enable smtp

also note that i've tried uploading the script on a web host to make sure that the problem is not in wampserver and got the same problem

but when i uploaded it to my vps where i have iredmail , the script worked and the mail was sent

14

Re: How to enable smtp

I'm afraid that it might be better to get support from phpmailer team. iRedMail just offers standard services for your use, and your application should work with them.

15

Re: How to enable smtp

is there any application that you would recommend to try if the smtp is well setted ? i'm just curious if my server blocks connections from the outside or not

thank you once again

16

Re: How to enable smtp

Try with a MUA, e.g. Thunderbird.

17

Re: How to enable smtp

i've tried the smtp settings on thunderbird so the problem is in the php script and not the smtp settings , thanks for your help smile