My current setup is a Postfix installation configured with DKIM on a server with hostname prod01.example.com The server is used to send out mail on the form email@example.com, firstname.lastname@example.org, etc. The setup works perfectly, and all mails are signed correctly using DKIM. Note, the server is and should only be used to send mail. Below are the relevant configurations:
myhostname = example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname # the file contains example.com mydestination = prod01.example.com, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = inet_interfaces = all inet_protocols = ipv4 home_mailbox = Maildir/ mailbox_command = # DKIM milter_default_action = accept milter_protocol = 2 smtpd_milters = inet:localhost:8891 non_smtpd_milters = inet:localhost:8891
Domain example.com KeyFile /etc/mail/dkim.key Selector mail
I would like to hear what the best/preferred way to extend the above configuration to allow the server to send out and sign mail from domains example2.com and example3.com
I did some simple testing using the following PHP code:
$to = 'my@gmail_address.com'; $subject = 'test'; $message = 'test'; $headers = 'From: email@example.com' . "\r\n" . 'Reply-To: firstname.lastname@example.org' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers);
The above code does in fact send the mail, but the mail is of course not signed correctly. Furthermore, if I look at the mail in Gmail it says: From email@example.com via example.com
So basically want I is a way for the server to send out mail as example2.com, without implying that the mail was send from example.com (such that Gmail does not write via example.com), and that the mails are correctly signed.
A google search reported many hits on virtual domains in Postfix, but as far as I can tell, they are only used if the server should receive mails and be final destination from multiple domains. I also found the following post, DKIM sign outgoing mail from any domain (with Postfix and Ubuntu), which more or less does the same thing as I want. However, the post is rather old, and I would to see if this is still the way to do it.