Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a machine with two domain names, say a.com and b.com.

When I use postfix to send something from an address like foo@a.com, it replaces it with foo@b.com every time. My main.cf file specifies only a.com so I don't know where the b.com is coming from.

Here's the relevant part of maillog... the first line is the intiation of the message and then the 6th line is the one where jim@b.com mysteriously pops up.

mymachine sendmail[28543]: qA3NGbOR028543: from=jim@a.com, size=792, class=0, nrcpts=1, msgid=<...@a.com>, relay=apache@localhost
mymachine postfix/smtpd[28546]: connect from b.com[]
mymachine postfix/smtpd[28546]: 912F9758031: client=b.com[]
mymachine postfix/cleanup[28549]: 912F9758031: message-id=<...@a.com>
mymachine sendmail[28543]: qA3NGbOR028543: to=someone@gmail.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30792, relay=[] [], dsn=2.0.0, stat=Sent (Ok: queued as 912F9758031)
mymachine postfix/qmgr[28527]: 912F9758031: from=<jim@b.com>, size=1130, nrcpt=1 (queue active)

I'm not sure if it's relevant how I called this, but it's from some PHP mail() and I've ensured the -f flag is passed along. If any more info might help I'd be happy to deliver it!

share|improve this question
I also found this which is a similar problem, but was not answered: serverfault.com/questions/144986/… –  daveagp Nov 3 '12 at 23:47

1 Answer 1



I found it was easier just to uninstall sendmail, install postfix, and use a Python script to send the mail. Here is the Python 3 code which I used to send the message (it needed to be internationalized hence the UTF-8 encodings).

import email.message, email.mime.text, smtplib, sys
from email.utils import parseaddr, formataddr
from email.header import Header
from email.charset import Charset

def format_address(name, email):
    if not name:
        return email
    name = Charset('iso-8859-1').header_encode(name)
    return formataddr((name, email))

def send_unicode_email(mFrom, mTo, mSubject, mBody):
    sender_name, sender_addr = parseaddr(mFrom)
    recipient_name, recipient_addr = parseaddr(mTo)

    composed = email.mime.text.MIMEText(mBody.encode('UTF-8'), _charset='UTF-8')
    composed['from'] = format_address(sender_name, sender_addr)
    composed['to'] = format_address(recipient_name, recipient_addr)
    composed['subject'] = Header(mSubject, 'UTF-8')

    srv = smtplib.SMTP('localhost')
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.