Sending Emails From Multiple Domains via Google Apps??
Up front, let me say that I am not currently a Linode customer, just in case the affects whether or not you answer my question. However, I know there are smart people around here, so I am hoping you can look beyond that.
Also, I will admit upfront that email setup is not my forte in any way, shape or form – and my current setup could be inefficient.
Anyway, I have gone through many of the posts on this forum and elsewhere, but I am admittedly just plain confused and can't put my finger on how to best accomplish what I want to do. I am running Ubuntu Hardy. Right now, I host two domains on my VPS, each, of course, represented as a separate vhost entity. Let's call them:
d1.com
d2.com
d1.com is a Wordpress installation
d2.com is a regular website with notification capability after an order was placed, for example.
Also, email for these domains are hosted via Google Apps.
Right now, I am also using Exim4 (maybe that's the problem, I don't know). I am only sending email. I have not set anything up to receive email. My Exim4 configuration (via the passwd.client file -- that is the appropriate file, right?) is setup such that all of my email is going through Google Apps in d2.com. Let's call it:
Now, anytime a comment is left on a blog post at d1.com, or someone makes an order at d2.com, an email is sent out looking like the following:
From: Sales <
Subject: You have a sale
Date: June 7, 2009 2:12:32 PM PDT
To:
Reply-To:
OR
From: Wordpress <
Subject: You have a comment
Date: June 7, 2009 2:12:32 PM PDT
To:
I want the From: line, especially for d1, to be
I tried adding
My passwd.client file (in /etc/exim4/) settings look like:
mail-smtp.l.google.com:
*.google.com:
smtp.gmail.com:
If I understand Exim correctly, it is using this account information to actually forward the email to the appropriate account for sending. To my eyes it is seeming like that email that is forwarded from exim with the email address that I specified in my Wordpress installation (
Do you think Exim is the cause here? Or am I missing something? I am just stuck.
It has been suggested that maybe PostFix or msmtp might be easier to configure in this case, but I don't want to go through the trouble of changing if I am missing something more fundamental.
Any advice would be appreciated. Thanks!
Joel
BTW, here are possible some relevant posts:
My post on the Slicehost forum (although as you will notice at the end of the discussion thread, I made some modifications to match what I posted above):
This Linode Forum post using Postfix (although I am not sure that helps with multiple domains):
6 Replies
$ sudo dpkg-reconfigure exim4
(I'm not sure if this is correct, but if it is, it should lead you through a wizard asking how to set up your email.)
The address that emails appear to come from is then set up by the program sending them, so you should be able to configure it in Wordpress. (I've never used Wordpress, though, so I can't tell you how to do that.)
@Sophira:
You don't need to have Exim send emails through your Google Apps account; it can send emails itself. Set it up as a regular mail server that doesn't use a smarthost; you should, I think, be able to do this with:
$ sudo dpkg-reconfigure exim4
(I'm not sure if this is correct, but if it is, it should lead you through a wizard asking how to set up your email.)
The address that emails appear to come from is then set up by the program sending them, so you should be able to configure it in Wordpress. (I've never used Wordpress, though, so I can't tell you how to do that.)
Sophira, thanks for your reply. Let me give you and everyone an update:
I basically decided to scrap exim (i.e., purge it), and start anew with my email infrastructure. As you can read above, basically my goal was to have a send only mail infrastructure that relays all outgoing email to Google Apps. I also wanted to where email from domain1 (a Wordpress installation) would show it coming from domain1.com and email from domain2 (a normal website) would show it coming from domain2.com.
So I decided to give PostFix a try. I literally followed the surprisingly simple instructions here:
And voila, all seems to be working as I expected. My email tests show email coming from the proper locations (either domain1 or domain2 depending on where the emails were sent from).
But this all seemed too simple to me. So simple, in fact, that I feel that something is amiss.
When I installed PostFix according to the instructions in the post above and it worked, I was surprised that I didn't have to specify an SMTP server, a port number, any authentication credentials, etc. My VPS is set up such that I have MX records for Google Apps (e.g., ASPMX.L.GOOGLE.COM.) in my DNS settings, but I am not sure if that is why it is working.
My email infrastructure knowledge is admittedly limited, but with this am I suspect to:
1. Spammers using my email infrastructure?
2. My emails going to people as spam?
3. Something else sinister?
I have actually stopped running PostFix until I understand this better.
Thanks!
@JoelMarcey:
(…)
As you can read above, basically my goal was to have a send only mail infrastructure that relays all outgoing email to Google Apps. I also wanted to where email from domain1 (a Wordpress installation) would show it coming from domain1.com and email from domain2 (a normal website) would show it coming from domain2.com.
(…)
But this all seemed too simple to me. So simple, in fact, that I feel that something is amiss.
When I installed PostFix according to the instructions in the post above and it worked, I was surprised that I didn't have to specify an SMTP server, a port number, any authentication credentials, etc. My VPS is set up such that I have MX records for Google Apps (e.g., ASPMX.L.GOOGLE.COM.) in my DNS settings, but I am not sure if that is why it is working.
Well, the first thing to realize is that the configuration you are using just has your Postfix sending mail directly to the destination - there's no physical hop through any of Google's servers, other than of course if Google's servers are the mail servers for the domain a message is being sent to. I'm not sure why you would particularly need to relay through Google to achieve your other goals.
SMTP email has the distinction between the physical hosts used to transfer the messages versus the messages themselves and the email addresses involved. There's a further separation between address information in the envelope of the SMTP transaction and the addresses in the headers of the message which are shown to recipients.
As an analogy to a real world letter, think of:
* The mail server used to transmit the message as the specific post office (or post office mailbox) that you put your letter in.
The email addresses used in the SMTP envelope during the protocol exchange (typically handled automatically by Postfix) as the addressing information (including return address) on the envelope.
The email address in the email headers that are shown to the user as the information on the letterhead of the actual letter inside the envelope.
Delivery of a letter by the post office is only based on its destination on the envelope - it doesn't matter what post office you drop it off at or what you put on the return address, or for that matter on the letter itself. Similarly, SMTP (a store and forward network) is looking to get the message to its destination address from the protocol transaction at each hop, regardless of which server the message started at.
So there's nothing technical that requires your Postfix installation to physically hand a message off to Google's servers just because you want to use a domain name in an address that is handled by Google Apps. Part of what Postfix is built to do (as an MTA or mail transfer agent) is determine what the best "next hop" is for a message - typically by a DNS lookup, or alternatively with local configuration - and hand the message to the best server.
Now, if the destination of the message is the Google Apps server itself (because Google Apps has been set up to receive mail for that domain), your Postfix will identify that it needs to send a message to Google automatically - just as if any other mail system out on the Internet tried to send a message to that domain.
If you look at the entries in /var/log/mail.log for some of your test messages, the "relay=" part of a delivery log message will indicate which physical server your local Postfix handed the message off to.
All this is not to say that some servers might not let you use them to relay messages to domains they aren't responsible for locally - in fact, that's how most home users use "smart" SMTP relays provided by their ISPs. But such relays are typically locked down either to customers or through authentication. You can configure Postfix to route messages that way, but why bother when Postfix can identify the best server to directly receive the message without another relay hop? I'm not familiar enough with Google Apps to know if it even offers servers for such relaying - though there are GMail relay servers if you can authenticate with a GMail account, so it might be similar.
One caveat in this discussion is that there are sometimes protections that various receiving servers may implement to try avoid mail forgeries. Since your Linode is not the declared receiver (via the DNS MX or A) for mail for the domain in question, you might look into adding an SPF DNS record for your domain listing your server as a valid mail server for the domain.
In terms of the exposure of your configuration for other purposes, the Postfix default configuration will prevent its use as a relay for connections from anywhere other than the networks listed in the "mynetworks" parameter, which by default is usually just localhost. You can also disabling it from even listening for inbound connections if you're using it strictly for outbound mail.
– David
I'm using Google Apps for recieving mail too. Using postfix to send mails from php scripts. (mail() function)
With this setup, any user on my linode send mail to anywhere using any address (after setup their email headers)
Its possible to use gmail as a relayhost. I tried it before using my email address that i created at google aps. But this time any user on my linode wants to send mail, it sends from my email address.
Can i configure postfix for multiple accounts?
I configure postfix to send email only using users domain name addresses.
Also i want to restrict users outgoing email to for example 300 relay
Any help would be appreciated
Thanks
Kerem
@krmdrms:
First of all, sorry about my not so good english skills
:oops: I'm using Google Apps for recieving mail too. Using postfix to send mails from php scripts. (mail() function)
With this setup, any user on my linode send mail to anywhere using any address (after setup their email headers)
Its possible to use gmail as a relayhost. I tried it before using my email address that i created at google aps. But this time any user on my linode wants to send mail, it sends from my email address.
Can i configure postfix for multiple accounts?
I configure postfix to send email only using users domain name addresses.
Also i want to restrict users outgoing email to for example 300 relay
Any help would be appreciated
Thanks
Kerem
If I understand your problem, I think it is the same as what I was experiencing. All email, no matter from where, was all being sent with the same From: address. Supposedly there is a way to get around this by adding some alternative From Addressing in the Gmail/Google App settings, but I was not able to get it to work.
I think you can accomplish what you want, but I will need to leave it to the experts to give you the details.
@db3l:
Well, the first thing to realize is that the configuration you are using just has your Postfix sending mail directly to the destination - there's no physical hop through any of Google's servers, other than of course if Google's servers are the mail servers for the domain a message is being sent to. I'm not sure why you would particularly need to relay through Google to achieve your other goals.
:
:
In terms of the exposure of your configuration for other purposes, the Postfix default configuration will prevent its use as a relay for connections from anywhere other than the networks listed in the "mynetworks" parameter, which by default is usually just localhost. You can also disabling it from even listening for inbound connections if you're using it strictly for outbound mail.
– David
David, you went above and beyond with your explanation and it really helped. Thank you very much.