LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-29-2011, 08:28 AM   #1
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Rep: Reputation: 0
postfix address re-write


Hi,

I have a server which runs postfix. The same physical server is running web and mail services for several (3) domains, which I have reserved for future use (nothing serious or valuable, just freetime activities).

Server "physical" address (also static IP) is myhost.domain.com. Lets say the other domains it serves are first.fi, second.net ad third.com. I can receive mails OK sent to all of these, I have added those 3 "extra" domains to the mydestination line in main.cf.

Sending e-mails also works fine, but the sender is user@myhost.domain.com.

I want the sender to be firstname@first.fi

I tried setting sender_canonical_maps = hash:/etc/postfix/sender_canonical in main.cf, and sender_canonical contains:

user1 Firstname1@first.fi
user2 Firstname2@first.fi

and I run postmap /etc/postfix/sender_canonical, and e-started postfix.

But if I send e-mail as user1, the sender becomes Firstname1@myhost.domain.com, so it re-writed the username part, but hot the hostname/domain part.

I also tried setting smtp_generic_maps = hash:/etc/postfix/generic but the results were similar.

What do I need to do to re-write sender for user1 (regardless of host/domain) to Firstname1@first.fi?

-Paavo
 
Old 03-30-2011, 11:12 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
why don't you just set the sender address in the client?
 
Old 03-31-2011, 05:35 AM   #3
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Can you check what was replaced when by lokking at the various logfiles of postfix? For me it's working, but I'm using a regexp instead of a hash.
 
Old 03-31-2011, 07:40 AM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
I would look here: http://www.postfix.org/ADDRESS_REWRITING_README.html. The top part of the page says that you can rewrite the host and domain, and I assume that the article discusses how.
 
Old 03-31-2011, 03:32 PM   #5
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Berhanie View Post
why don't you just set the sender address in the client?
But I have tried this... somewhat.

This might not be an postfix problem, since outlook sends mails with Firstname1@first.fi as sender,
outlook configuration is Name = "Firstname Familyname" and E-mail-address = "Firstname1@first.fi".
So outlook works just like it should

BUT, if the client is SquirrelMail, and Optios -> Personal Information Full Name is empty and
also E-mail Address is empty, the "final" sender is user1@myhost.domain.com (like it should be);
SM uses user1@localhost as sender, but it gets "translated" to user1@myhost.domain.com somewhere.

If I configure SM Full Name = "Firstname Familyname" and E-mail-address = "Firstname1@first.fi",
then the final sender becomes Firstname1@myhost.domain.com. Relevat part of /var/log/maillog:

Quote:
Mar 31 23:20:50 myhost sendmail[17580]: xxx: Authentication-Warning: myhost.domain.com: apache set sender to Firstname1@first.fi using -f
Mar 31 23:20:51 myhost sendmail[17580]: xxx: from=Firstname1@first.fi, size=538, class=0, nrcpts=1, msgid=<aaa.squirrel@myhost.domain.com>, relay=apache@localhost
Mar 31 23:20:51 myhost postfix/smtpd[17581]: connect from myhost.domain.com[127.0.0.1]
Mar 31 23:20:51 myhost sendmail[17580]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
Mar 31 23:20:51 myhost postfix/smtpd[17581]: yyy: client=myhost.domain.com[127.0.0.1]
Mar 31 23:20:51 myhost postfix/cleanup[17585]: yyy: message-id=<aaa.squirrel@myhost.domain.com>
Mar 31 23:20:51 myhost sendmail[17580]: zzz: to=someone@testmail.com, delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30538, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as bbb)
Mar 31 23:20:51 myhost postfix/qmgr[17573]: bbb: from=<Firstname1@myhost.domain.com>, size=993, nrcpt=1 (queue active)
Mar 31 23:20:51 myhost postfix/smtpd[17581]: warning: network_biopair_interop: error reading 5 bytes from the network: Connection reset by peer
Mar 31 23:20:51 myhost postfix/smtpd[17581]: disconnect from myhost.domain.com[127.0.0.1]
Mar 31 23:20:51 myhost postfix/smtp[17586]: bbb: to=<someone@testmail.com>, relay=mailsrv.someisp.fi[210.220.230.240]:25, delay=0.3, delays=0.13/0/0.11/0.06, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 808DA5D802D)
Mar 31 23:20:51 myhost postfix/qmgr[17573]: bbb: removed
So SM is using sendmail. Do I need to tell sendmail it's OK to send mails from first.fi domain?

-Paavo

Last edited by Paavo; 04-01-2011 at 12:51 AM.
 
Old 03-31-2011, 04:07 PM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
it's a little unusual, running both sendmail and postfix. what's the reason for that?
 
Old 04-01-2011, 12:43 AM   #7
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Berhanie View Post
it's a little unusual, running both sendmail and postfix. what's the reason for that?
I also have Dovecot IMAP server running in this, outlook uses that. Not sure if SM uses sendmail directly or via Dovecot?

-Paavo
 
Old 04-01-2011, 12:46 AM   #8
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

here is received message header, when the message is sent from outlook:

Quote:
Return-Path: <Firstname1@first.fi>
X-Original-To: someone@testmail.com
Delivered-To: receiverrealusername@mailfront.someisp.fi
Received: from myhost.domain.com (unknown [110.120.130.140])
by mailfront.someisp.fi (Postfix) with ESMTP id xxx
for <someone@testmail.com>; Thu, 31 Mar 2011 hh:mm:ss +0300 (EEST)
Received: from myclient (myclient.wipsl.com [110.120.130.141])
by myhost.domain.com (Postfix) with ESMTPS id xxx
for <someone@testmail.com>; Thu, 31 Mar 2011 hh:mm:ss +0300 (EEST)
From: "Firstname Familyname" <Firstname1@first.fi>
To: <someone@testmail.com>
Subject: zzz
Date: Thu, 31 Mar 2011 hh:mm:ss +0300
Message-ID: xxx
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Acvv20bt7DJUdfmmSteBIOZZp8ksjw==
Content-Language: fi
x-cr-puzzleid: {bbb}
x-cr-hashedpuzzle: <<<very long line removed>>>
And here is received message header, when the message is sent from squirrelmail:

Quote:
Return-Path: <Firstname1@myhost.domain.com>
X-Original-To: someone@testmail.com
Delivered-To: receiverrealusername@mailfront.someisp.fi
Received: from myhost.domain.com (unknown [110.120.130.140])
by mailfront.someisp.fi (Postfix) with ESMTP id xxx
for <someone@testmail.com>; Thu, 31 Mar 2011 hh:mm:ss +0300 (EEST)
Received: from myhost.domain.com (myhost.domain.com [127.0.0.1])
by myhost.domain.com (Postfix) with ESMTPS id xxx
for <someone@testmail.com>; Thu, 31 Mar 2011 hh:mm:ss +0300 (EEST)
Received: (from apache@localhost)
by myhost.domain.com (8.14.4/8.14.4/Submit) id xxx;
Thu, 31 Mar 2011 hh:mm:ss +0300
X-Authentication-Warning: myhost.domain.com: apache set sender to Firstname1@first.fi using -f
Received: from 110.120.130.140
(SquirrelMail authenticated user user1)
by myhost.domain.com with HTTP;
Thu, 31 Mar 2011 hh:mm:ss +0300
Message-ID: xxx
Date: Thu, 31 Mar 2011 hh:mm:ss +0300
Subject: yyy
From: "Firstname Familyname" <Firstname1@myhost.domain.com>
To: someone@testmail.com
User-Agent: SquirrelMail/1.4.21-1.fc14
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3 (Normal)
Importance: Normal
Not sure if these help, I need to take a closer look at SM configuration, and
maybe start from $useSendmail (now set to true, in /etc/squirrelmail/config.php).

-Paavo

Last edited by Paavo; 04-01-2011 at 12:52 AM.
 
Old 04-01-2011, 02:16 AM   #9
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
ah, ok, so it looks like squirrelmail is invoking sendmail's sendmail binary instead of postfix's sendmail binary.
my squirrelmail config is this:
Code:
$useSendmail            = true;
$sendmail_path          = '/usr/sbin/sendmail';
$sendmail_args          = '-i -t';
note the line in bold. i don't have any sendmail packages on my system, but the line refers to
postfix's "sendmail" program, which submits mail through the file system instead of through the
tcp/ip stack (via the smtp). since you have both postfix and sendmail installed, there's a confusion
when taking about "the sendmail" binary. you can set sendmail_path to the location of the
sendmail that came with postfix, e.g. "$sendmail_path = '/usr/sbin/sendmail.postfix'", but this is
not a general solution, because you'll have problems again when you use the "mailx" program, for
example.

to fix it once and for all, you can do one of two things:

1. uninstall all sendmail packages.
2. keep both sendmail and postfix packages around, but tell your system (using your distro's configuration
tools) that postfix is the mail server that you're using. the system will then do such things as associate
/usr/sbin/sendmail with postfix's version.
 
Old 04-01-2011, 04:19 AM   #10
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

I configured SM to use smtp (had to disable smtp tls, since my SM is 1.4.x and does not support STARTTLS yet), and now the sender domain is OK, i.e. what is set in Optios -> Personal Information E-mail Address field.

I also need to check if I should completely remove sendmail. I'm more familiar with postfix, and therefore I have just used chkconfig to disable sendmail and enable postfix (after congifuring postfix properly).

So this was not a postfix problem, it works well with my original settings. Also dovecot is OK, the only change I did was configure squirrelmail to use smtp (direct conection to postfix) instead id sendmail (wrappers).

Thanks for everybody do contributed, this problem has been bothering me for some time, but it seems to be working now.

-Paavo
 
Old 04-01-2011, 07:57 AM   #11
Paavo
LQ Newbie
 
Registered: May 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

> I also need to check if I should completely remove sendmail

I have Fedora 14, and 'alternatives --config mta' and choose postfix instead of sendmail
did the trick, I don't see a need to remove sendmail packages.

-Paavo

Quote:
# alternatives --display mta
mta - status is manual.
link currently points to /usr/sbin/sendmail.postfix
/usr/sbin/sendmail.sendmail - priority 90
slave mta-pam: /etc/pam.d/smtp.sendmail
slave mta-mailq: /usr/bin/mailq.sendmail
slave mta-newaliases: /usr/bin/newaliases.sendmail
slave mta-rmail: /usr/bin/rmail.sendmail
slave mta-sendmail: /usr/lib/sendmail.sendmail
slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
/usr/sbin/sendmail.postfix - priority 30
slave mta-pam: /etc/pam.d/smtp.postfix
slave mta-mailq: /usr/bin/mailq.postfix
slave mta-newaliases: /usr/bin/newaliases.postfix
slave mta-rmail: /usr/bin/rmail.postfix
slave mta-sendmail: /usr/lib/sendmail.postfix
slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
Current `best' version is /usr/sbin/sendmail.sendmail.
# exit
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to read/write a 16-bit address e2prom? giampaquestions Linux - Embedded & Single-board computer 2 08-15-2010 02:00 PM
How to read/write physical address in Linux. VegasGod Linux - Newbie 3 05-18-2010 09:48 AM
Postfix outgoing address whaase Linux - Server 4 02-23-2009 09:42 AM
Postfix address slipsy Linux - Networking 0 09-24-2003 05:56 AM
Can't write in the mapped address space zhangfaquan Linux - Software 0 01-14-2003 08:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration