We need to send email using PHP's mail() function (Actually CakePHP, which wraps that function) directly from our dedicated server (app.ourserver.com). We would like to send mail from app.ourserver.com, but need to send it as mail.domain1.com AND mail.domain2.com. We don't want to use STMP as it's slow to connect, especially to our external mail servers (mail.domain1.com AND mail.domain2.com). I've tried to add proper SPF records to the two domains domain1.com and domain2.com, to allow ourserver.com to send out email, but the email gets immediately discarded as SPAM on the receiving end. How would we go about doing this, without using authenticated SMTP accounts on our external domains?

  • Does ourserver.com have properly setup RDNS and working as a proper MTA? – Gmck Jan 27 '16 at 19:29
  • Eeek! I'm not sysadmin material, hence the questions - Just a dev trying to figure this stuff out :) EDIT: If we are talking about PTR, yes that record is setup and working... but MTA... I wouldn't have a clue – MKUltra Jan 27 '16 at 23:37
  • MTA refers to a Mail Transfer Agent - such as Postfix. Another thing, the sender's address should not be the recipient's address. This happens quite often whith automated emails based on some user input. – Gmck Jan 28 '16 at 2:37
  • Ah, right. The MTA is sendmail, and it does send, but in the mail logs the emails are being discarded by the receiving servers. – MKUltra Jan 28 '16 at 18:34
  • Sendmail's sending logs on your server should not be discarded. Have a look in /var/log/ - they are usually there under mail.log. Gmail SMTP servers will usually give an indication of the issues. – Gmck Jan 28 '16 at 20:20

I think your title is incorrect. Should it be "How do I send eMail from another Domain?" or something like that.

There are any number of reasons you get classified as spam:

  • rDNS validation doesn't work for IP address (PTR -> A -> PTR).
  • rDNS validation doesn't work for the name you use in the HELO or EHLO command.
  • Nothing is answering on port 25 on your server. You may need to set up a local mail server, not that I would recommend you do so.
  • You are blacklisted (check your IP and domain).
  • SPF is failing.
  • DMARC is failing.

If you look at the headers of a message classified as spam, there may well be headers telling you why it was classified as spam.

Your first choice should be to use a relay server which is permitted to send mail for your domain. Connecting to the submission port (which may require authentication) should be quite fast. The fact that you find connecting to the domain's mail servers very slow may indicate that your are triggeting spam avoidance rules there. (My rules provide slow service to poorly configured hosts and express service to well configured hosts. This drops lots of spam.)

  • Hi @BillThor, thanks for the response. I didn't check to see if the host we are sending mail from is blacklisted, I will do that. SPF may be failing, which is part of my question... what would the SPF record look like in the given scenario? No idea what DMARC is, but will Google it. Thanks for your help! – MKUltra Jan 28 '16 at 18:25
  • @MKUltra The SPF record would look something like 'v=spf1 mx a:yourhost.example.com -all'. Search for "spf generator" for tools. You may find more hints at systemajik.com/blog/detecting-email-server-forgery including some tools to verify your setup. – BillThor Jan 29 '16 at 3:41
  • Thanks @BillThor, my SPF looks much more convoluted than that example. I did use a generator, but it made a very verbose and incorrect SPF record from what I could tell. I will try again this weekend with a different SPF. – MKUltra Jan 29 '16 at 22:35

You can set up SSMTP, a lightweight program that replaces postfix and is good for just sending email out - but it doesn't receive email. You can set the from address. It works well for me. Setup is slightly fiddly so you'll need to find a guide or tutorial - mine won't be out for a week or so.

  • Hey Tim, Thanks for the answer. I would not be able to implement that myself, but I would love to have a link to your tutorial on here so that others may reference it, when you make it available. – MKUltra Jan 29 '16 at 22:33
  • Sure - photographerstechsupport.com/blog - maybe a week until it's out. – Tim Jan 29 '16 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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