Restrict SMTP use to localhost

Discussion in 'Installation/Configuration' started by NeeChee, Aug 2, 2009.

  1. NeeChee

    NeeChee New Member

    Hi everybody! I'm running a mailserver with ISPCONFIG 3 (Duh) and I'd like to restrict SMTP use to the localhost only so that my clients can only send mail via my server through webmail.

    I've tried closing the 25 port, but that will prevent mail from being recieved by the server.

    How on earth do I do this?

    Thanks in advance!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Edit the file /etc/postfix/main.cf

    and remove

    "permit_sasl_authenticated"

    from the line

    smtpd_recipient_restrictions = ......

    and restart postfix.
     
  3. NeeChee

    NeeChee New Member

    This won't work for me, the roundcube webmail client I use, uses sasl authentification. I need something to disallow all other hosts than localhost.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    This works perfectly as roundcube does not have to use sasl as it is installed on localhost. Just reconfigure your roundcube so that it sends from localhost without sasl.
     
  5. NeeChee

    NeeChee New Member

    I'm not sure how to configure roundcube then... then again I'm a bit of a noob at this. This is my current roundcube configuration.

    Code:
    [...]
    // use this host for sending mails.
    // to use SSL connection, set ssl://smtp.host.com
    // if left blank, the PHP mail() function is used
    $rcmail_config['smtp_server'] = 'localhost';
    
    // SMTP port (default is 25; 465 for SSL)
    $rcmail_config['smtp_port'] = 25;
    
    // SMTP username (if required) if you use %u as the username RoundCube
    // will use the current username for login
    $rcmail_config['smtp_user'] = '%u';
    
    // SMTP password (if required) if you use %p as the password RoundCube
    // will use the current user's password for login
    $rcmail_config['smtp_pass'] = '%p';
    
    // SMTP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
    // best server supported one)
    $rcmail_config['smtp_auth_type'] = '';
    [...]
    
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Just change:

    $rcmail_config['smtp_server'] = 'localhost';

    to:

    $rcmail_config['smtp_server'] = '';
     
  7. NeeChee

    NeeChee New Member

    Won't that stress my PHP too much, since it is then using the mail() function. Your help is appreciated by the way.
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    The php mail function uses less resources then using smtp.
     
  9. NeeChee

    NeeChee New Member

    Okay, thanks for your help, I'll use this then.

    I did find another solution I'll just post here just for documentation.
    In /etc/postfix/main.cf

    Just change:

    inet_interfaces = all

    to:

    inet_interfaces = localhost
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats not a solution as it also disables receiving for the local mail accounts.
     
  11. NeeChee

    NeeChee New Member

    My mistake. I withdraw that XD
     

Share This Page