Koozali.org: home of the SME Server

SME Server and mail server from Google Apps

Offline jncs

  • **
  • 31
  • +0/-0
SME Server and mail server from Google Apps
« on: November 03, 2009, 09:59:07 PM »
Hi,

I have a primary domain (myprimarydomain.com) and several virtual domains.
One of those virtual domains (myvirtualdomain.com) is configured in my registrar to use mail servers from Google Apps. (MX)

Everything is ok when I send and receive mail from myvirtualdomain.com.

The problem is when my SME Mail Server from myprimarydomain.com tries to send mail to myvirtualdomain.com.

I get the following message in my admin account from myprimarydomain.com (MAILER-DAEMON@myprimarydomain.com):



Hi. This is the qmail-send program at myprimarydomain.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<myname@xyz.myprimarydomain.com>:
Recipient unknown

--- Below this line is a copy of the message.

Return-Path: <admin@myvirtualdomain.com>
Received: (qmail 26780 invoked by alias); 3 Nov 2009 19:22:43 -0000
Delivered-To: alias-localdelivery-myname@myvirtualdomain.com
Received: (qmail 26777 invoked by uid 102); 3 Nov 2009 19:22:43 -0000
To: myname@myvirtualdomain.com
Subject: =?iso-8859-1?B?TW9vZGxlIHwgSm9yZ2UgU2lsdmE6IGNvbmZpcm1h5+NvIGRlIGFsdGVy?=  =?iso-8859-1?B?YefjbyBkYSBzZW5oYQ==?=
Date: Tue, 3 Nov 2009 20:22:43 +0100



I've tried already to setup both domains to use Internet DNS Servers but the problem is the same.
I think this is a qmail misconfiguration error...
Because the SME Server knows that both domains are in the same server it don't send mail outside the SME Server.
I have already deleted the entry "mail.myvirtualdomain.com" from Hosts and Address in Server Manager.

Anyone can help me?
Jorge Silva

Offline paradigm

  • *
  • 96
  • +0/-0
Re: SME Server and mail server from Google Apps
« Reply #1 on: November 06, 2009, 04:09:08 PM »
Maybe you should add "mail.myvirtualdomain.com" and "myvirtualdomain.com" with the ip adress of the google Apps

Mail server to your Hosts and Address in Server Manager , this way mail sent to that domain will be routed outside

Sme server and not inside it .....

Just my 2cents.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: SME Server and mail server from Google Apps
« Reply #2 on: November 06, 2009, 07:24:52 PM »
Delete myvirtualdomain.com and add www.myvirtualdomain.com. Your SME server will then no longer interfere with mail for user@myvirtualdomain.com (but will only provide website content via http://www.myvirtualdomain.com/ and not http://myvirtualdomain.com/, assuming that you have DNS configured correctly. There's no easy workaround to this limitation - you would need to use custom templates for various parts of the mailsystem.

Offline jncs

  • **
  • 31
  • +0/-0
Re: SME Server and mail server from Google Apps
« Reply #3 on: November 06, 2009, 10:07:58 PM »
Maybe you should add "mail.myvirtualdomain.com" and "myvirtualdomain.com" with the ip adress of the google Apps

Mail server to your Hosts and Address in Server Manager , this way mail sent to that domain will be routed outside

Sme server and not inside it .....

Just my 2cents.

Doesn't works! I've already tried!
Jorge Silva

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: SME Server and mail server from Google Apps
« Reply #4 on: November 06, 2009, 10:12:13 PM »
Doesn't works!

In which way does it not work?

Offline jncs

  • **
  • 31
  • +0/-0
Re: SME Server and mail server from Google Apps
« Reply #5 on: November 06, 2009, 10:34:18 PM »
Delete myvirtualdomain.com and add www.myvirtualdomain.com. Your SME server will then no longer interfere with mail for user@myvirtualdomain.com (but will only provide website content via http://www.myvirtualdomain.com/ and not http://myvirtualdomain.com/, assuming that you have DNS configured correctly. There's no easy workaround to this limitation - you would need to use custom templates for various parts of the mailsystem.

Thanks!

I lookup for the qmail configuration files...
I could verify that all the configuration files were in the /var/qmail/control.
So, I rewrite the templates files assuming that there has a domain property 'qmail' set to disabled:

Code: [Select]
db domains setprop myvirtualdomain.com qmail disabled

Then I edit and change /etc/e-smith/templates/var/qmail/control/rcpthosts/10standard

Code: [Select]
{
    use esmith::DomainsDB;

    my $ddb = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB\n";

    my @rcpt_hosts = ( "$SystemName.$DomainName" );

    foreach my $domain ( $ddb->get_all_by_prop( type => "domain" ) )
    {
        my $qmail = $domain->prop('qmail') || 'enabled';
        if ($qmail eq 'enabled')
        {
               push @rcpt_hosts, $domain->key;
        }
    }
    $OUT = join "\n", @rcpt_hosts;
}

I also edit and change /etc/e-smith/templates/var/qmail/control/virtualdomains/80localdomains:

Code: [Select]
{
    $OUT = '';

    use esmith::DomainsDB;
    my $domainsdb = esmith::DomainsDB->open_ro();

    for my $domain ($domainsdb->domains)
    {
        my $mail_server = $domain->prop('MailServer')
                          || $DelegateMailServer
                          || 'localhost';

        next if ( $mail_server ne 'localhost' );

        $emaildomain = $domain->key;
        my $handler = $domain->prop('EmailTo') || "alias-localdelivery";
        my $qmail = $domain->prop('qmail') || 'enabled';
        if ($qmail eq 'disabled')
        {
       $OUT .= "#------------------------------------------------------------\n";
       $OUT .= "# To qmail use this domain delete the key\n";
       $OUT .= "# qmail\n";
       $OUT .= "# from db domains with the command:\n";
       $OUT .= "# db domains delprop $emaildomain qmail\n";
               $OUT .= "# $emaildomain:$handler\n";
               $OUT .= "#------------------------------------------------------------\n";
        }
        else
        {
       $OUT .= "$emaildomain:$handler\n";
        }
    }
}

After this:

Code: [Select]
expand-template /var/qmail/control/rcpthosts
expand-template /var/qmail/control/virtualdomains

And restarted qmail:

Code: [Select]
/etc/init.d/qmail restart

After all that everything is working as I want!  :P

I hope this could help more people!
Jorge Silva

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: SME Server and mail server from Google Apps
« Reply #6 on: November 06, 2009, 10:48:42 PM »
Then I edit and change /etc/e-smith/templates/var/qmail/control/rcpthosts/10standard

You should never edit any template file. You must use a custom template, or your edits will be lost at some time in the future when you install updates.

Offline jncs

  • **
  • 31
  • +0/-0
Re: SME Server and mail server from Google Apps
« Reply #7 on: November 06, 2009, 11:04:10 PM »
You should never edit any template file. You must use a custom template, or your edits will be lost at some time in the future when you install updates.

 :eek:

Does the custom templates overlap the standard templates when I use template-expand?

If I put those files in /etc/e-smith/templates-custom/var/qmail/control/... they overlap the standard templates when I execute:

Code: [Select]
expand-template /var/qmail/control/rcpthosts
expand-template /var/qmail/control/virtualdomains

Those standard templates create an entry to myvirtualdomain.com on rcpthosts and virtualdomains. How could I "delete" those entries with custom templates?
« Last Edit: November 06, 2009, 11:30:56 PM by jncs »
Jorge Silva