I need to install Postfix or Exim to be able to send emails from my web server's php code. I have a few questions hopefully I can find answers to:
Could mail be rejected or sent to spam on receiveing server if hostname of my machine is myhost.mydomain.com but I'm setting sender's email to [email protected]? What should I do? Should I just set my hostname to mydomain.com? Will this conflict with google apps in some way?
What will happen to bounced mail on a setup where I have not really configured incoming email and incoming email is handled by Google apps? Could this cause delivery problems?
Note: My google apps is setup to accept mail for [email protected], but my hostname of sender machine is myhost.mydomain.com. I will be sending emails from my server as [email protected]. If sent email bounces, will it go to Google or my server?
- Is it absolutely necessary to have SPF and DKIM configured with my ourgoing mail or not to ensure delivery?
I need a bit of info on how all this works and how it should be set up properly and I appreciate your help. Thank you in advance.
You are perfecly fine if you send mails from your host.example.com. The email address doesn't have to include any part of the hostname/domain. At least for a RFC valid email. Mails are normally delivered to the coreesponding MX-host which is known from the DNS. So for example if you want to sent a mail to [email protected] then your smtp daemon looks after the MX-record in the DNS and sends it to the found IP address. As a fallback if no MX-Record is given the A-record is looked up and then it is tried to deliver the mail to this host.
A bounce mail is sent to the given "From:" address. In your case this would be [email protected]. You mistake it with a reject.
A rejected mail is a mail where the recepient don't accept the mail from you. This could have various reasons - technical diffultities, spam filter, etc. If your mail gets temporarly rejected your smtp mailer (sendmail) will try it again. If after a certain time the mail isn't delivered or the destination has sent a permanent reject then your mailer will inform to the originating email address. If your Google Apps is in duty of this email address you should be fine. Something like [email protected] as sender email address should do the job.
The only tricky thing in your case could be the spamfiltering on the recipient side. Therefore you have to take care of some settings:
When you have an existing SPF record. This DNS record is something like a "reverse MX-record" and with it you tell the whole world who is allowed to send and relay mails from your domain. If you have one than your SPF-record should be so that host.example.com is per SPF allowed to send mail. Otherwise you may get a higher spam-score on your sent email.
You should also have a reverse and a-record for your sending host. And the a-record should match the hosts IP address. Your IP address should also be static.
Another thing is your HELO-Name. This one should be in best case your FQDN hostname.
PS: Be aware that you should use example.[com|org|net|edu] for examples where you don't want to mention your real domain.
It sounds like you have already done some considerable research on this subject and maybe you're at the point of "shopping for the right answer..."
Bottom line: If your SMTP server does not conform to the "typical" (which can vary some depending on who is testing and how they interpret things) parameters, then it stands a chance of not getting delivered (whether there are notifications or not with some interpretations) or classified as spam within the receiving systems.