Allow sending mail from local SMTP while still having external mail server

Discussion in 'Installation/Configuration' started by snoop168, Feb 14, 2020.

  1. snoop168

    snoop168 New Member

    I am running a website that needs to send mail. I use Office365 for normal users mailboxes. I want to be able to use the local servers SMTP to send mail from the website so that DKIM keys may be used. It seems to work as long as the "to" address isn't the same domain, otherwise the mail server realizes that the domain is hosted locally and tries to deliver locally but there is no such mailbox... If it instead looked up the MX record it would have sent to Office365 servers where the mailbox would be valid. Is there any way to make it work like this?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    If you create e-mail domain on that host, then it thinks it is the e-mail server for that domain.
    If Office365 handles e-mails, then you should not create e-mail domain on your server.
     
  3. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    the best option is not to have the website sent out mails directly. in fact, to help prevent spamming from compromised sites, it's best if the webservers firewall is configured to block that server making any outbound connections with a destination port of 25.
    ideally, in wordpress, you would use an smtp plugin, in joomla, I believe the smtp settings are set in the configuration file, to use the standard phpmailer, you'd need to add the smtp details as part of your code, so that the website connects to the email domains normal mailserver with an authenticated account and sends emails out through that, in your case this would be the office365 servers rather than a local smtp server. since the email is being submitted directly through the correct mailserver, ideally on port 587 with TLS/STARTTLS encryption, the dkim signature would be applied automatically.
    doing it this way, your webserver will never get it's ip blacklisted for sending out spam, because it can't.
     
  4. snoop168

    snoop168 New Member

    Thanks for the response. This server is both a web server (For the domain in question and other domains) and email server (primarily for other domains except for the webpage sending outbound messages) so blocking outbound port 25 would stop the email server from working right? But I would agree I don’t want the PHP scripts to be able to send out direct but not sure if I have a choice since the server is both a web and email server. Anyway seems like my best option is to use the office365 server to send the outbound like you suggest. Just for the record I was using smtp to the local host in the first place. Is there any other way to continue using the local email server since it’s still running anyway? Trying to avoid needing another office365 mailbox (no-reply mailbox) just for the webpage to send as. Not sure if email relay or something would accomplish what I’m trying to do. Basically tell the local server that if you receive any mail for a specific address reroute out to the office365 server?

    thanks again guys.
     

Share This Page