ISPConfig SMTP configuration

Discussion in 'Installation/Configuration' started by JULINT, Feb 17, 2024.

  1. JULINT

    JULINT Member

    Hi ,
    I have installed ispconfig successfully. But when i am testing with php library PHPmailer for sending email from PHP.
    I have tried with smtp port 25 and 26.

    I got this error message : SMTP Error: Could not connect to SMTP host.
    Please help me to solve this.

    Below is my php code example.

    $smtp_from = '[email protected]';
    $smtp_host = 'mail.tobiku.com';
    $smtp_username = '[email protected]';
    $smtp_password = 'xxxxxx';
    $smtp_port = 25;

    //send email
    $PHPMailer = new PHPMailer();

    $PHPMailer->IsHTML(true);
    $PHPMailer->From = $smtp_from;
    $PHPMailer->FromName = 'Tobiku';
    $PHPMailer->Sender = $smtp_from;
    $PHPMailer->AddReplyTo($smtp_from, 'Tobiku');

    $PHPMailer->Host = $smtp_host;
    $PHPMailer->Username = $smtp_username;
    $PHPMailer->Password = $smtp_password;
    $PHPMailer->Port = $smtp_port;

    $PHPMailer->IsSMTP();
    $PHPMailer->SMTPSecure = 'tls';
    $PHPMailer->SMTPAuth = true;


    $PHPMailer->Subject = 'Sbjct Email';

    $PHPMailer->IsHTML(true);

    $msg_html = 'Test body';

    $PHPMailer->MsgHTML($msg_html);


    $PHPMailer->AddAddress('[email protected]', "Username");
    $PHPMailer->Send();
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The SMTP port to send with authentication is 587. The SMTP port to use without authentication with server hostname "localhost" is 25.
     
  3. JULINT

    JULINT Member

    Hi Till,
    Thanks for your help..

    I have tried login to webmail via https://tobiku.com:8080/webmail , using user id and pwd for sending email, i can login to webmail.
    I have change port to 587, and it got new error : SMTP Error: Could not authenticate.



    Changes :
    Remove using tls

    Below is my php code example.

    $smtp_from = '[email protected]';
    $smtp_host = 'mail.tobiku.com';
    $smtp_username = '[email protected]';
    $smtp_password = 'xxxxxx';
    $smtp_port = 587;

    $PHPMailer = new PHPMailer();
    $PHPMailer->IsHTML(true);
    $PHPMailer->From = $smtp_from;
    $PHPMailer->FromName = 'Tobiku';
    $PHPMailer->Sender = $smtp_from;
    $PHPMailer->AddReplyTo($smtp_from, 'Tobiku');

    $PHPMailer->Host = $smtp_host;
    $PHPMailer->Username = $smtp_username;
    $PHPMailer->Password = $smtp_password;
    $PHPMailer->Port = $smtp_port;

    $PHPMailer->IsSMTP();
    $PHPMailer->SMTPAuth = true;
    $PHPMailer->Subject = 'Sbjct Email';
    $PHPMailer->IsHTML(true);
    $msg_html = 'Test body';

    $PHPMailer->MsgHTML($msg_html);


    $PHPMailer->AddAddress('[email protected]', "Username");
    $PHPMailer->Send();
     
  4. JULINT

    JULINT Member

    Hi ,

    I got this by running command line : openssl s_client -connect mail.tobiku.com:587 -starttls smtp


    Start Time: 1708161161
    Timeout : 7200 (sec)
    Verify return code: 18 (self signed certificate)
    Extended master secret: no
    Max Early Data: 0


    This error : Verify return code: 18 (self signed certificate) ,
    how to bypass this self signed certificate ?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    heck the PHPMailer documentation or ask its developer on how to set it to ignore a self-signed SSL cert or alternatively, install a signed cert. But the error 'could not authenticate' sounds more like a authentication issue and not a SSL connect issue, so you should double-check the username and password that you use and also check the mail.log to see what the mail server logs as error message for your auth attempt.
     
  6. JULINT

    JULINT Member

    Hi Till,
    Is there any tutorial of installatiion free ssl auto sign for ispconfig?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig does that by itself. If you have not created one during initial installation, then you can redo that by running an update:

    ispconfig_update.sh --force

    and choose to recreate the SSL cert during update. But take care that the server's hostname must have a valid DNS A-Record pointing to the server's IP and that let's encrypt must be able to access this hostname from the internet on port 80 and Let#s encrypt must not be blocked otherwise like by a CAA record, and you likely will not get a let#s Encrypt cert for automatically generated hostnames of larger providers, you must change the hostname then first to be a subdomain of one of your own domains.
     
    Last edited: Feb 17, 2024
    ahrasis likes this.
  8. lukafred

    lukafred New Member

    I am looking for a good HOWTO on how to effectively rollout an email server using the howtoforge tutorial "The Perfect Server - Debian Lenny with ISPConfig 3" as a baseline installation starting point.

    I have searched up and down howtoforge and other linux help forums to no avail ( I see tutorials for ISP Config 2, but it clearly states it will not work with ISPConfig 3 ), but I have started to favor this community for the fast responses and willingness to help =) so I will ask here first.

    Anyone have any experience and offer any insight on how to start a email server, configuration files worth looking at, external links to tutorials elsewhere, books, or anything I can learn about to start this service?

    Any help is, as always, very appreciated
     
    Last edited: Apr 9, 2024
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    This is a very old guide. Using such a old guide makes no sense. Use the recent one instead:

    https://www.howtoforge.com/ispconfig-autoinstall-debian-ubuntu/

    So, to install an email server, you would simply run this command on Debian 12:

    This will install a web server too but not for hosting websites, its just used for webmail and ISPConfig GUI

    Or if you want to do it manually for the learning experience, use this one:

    https://www.howtoforge.com/perfect-server-debian-12-buster-apache-bind-dovecot-ispconfig-3-2/
     

Share This Page