LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to use sendmail to send email alerts through Outlook? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-sendmail-to-send-email-alerts-through-outlook-4175614909/)

pcarlso7 10-02-2017 05:28 PM

How to use sendmail to send email alerts through Outlook?
 
I bought a Raspberry Pi for work to monitor some of our machines.
I wrote a bash script using sendmail to automatically send an alert email whenever one of them goes down/loses connection. The office uses MS Outlook for it's email service.

The issue I'm having is the email from the Pi keeps getting rejected as spam from the server, so I can't actually send out any emails. The server sends back a "Diagnostic-Code: SMTP; 550 5.7.606 Access denied, banned sending IP..." along with a ton of other code to the Pi telling it "No." The email is being sent from the local host, the Pi, and I'm pretty sure that's part of the problem.

I've tried adding the server name to the sendmail.mc file, using "define('SMART_HOST',my.server.com)dnl", but I don't really know enough to pin down what I should do. Some Googling has led to some other solutions, but nothing has worked so far.

My boiled down question (I think) is how do I get the email to send from the server instead of the Raspberry Pi? Or at least get the server to allow it to send without getting the Pi's IP address off the spam list.

MensaWater 10-04-2017 09:17 AM

Whoever administers your MS Exchange or MS Office365 mail has to allow the relay from the IP. As you might imagine by default most mail systems (even those from MS) by default reject relaying unless explicitly allowed.

pcarlso7 10-05-2017 01:14 PM

Thanks, that's what I ended up doing. Now I'm trying to fix the hostname issues, but that's a topic for another day.

Out of curiosity, do you know of another way to get the email through?

MensaWater 10-05-2017 01:35 PM

You could send directly to the internet rather than relaying through MS Exchange/Office 365.

However, that would likely require you to do additional DNS setup regarding your domain. If you already have SPF or TXT records restricting which servers can send on behalf of your domain others would reject you until you added the outbound IP of the sendmail server to those records. Additionally others often reject if you don't have a valid (in their mind) PTR showing the IP resolves to a "real" name. (e.g. We used to have PTRs that simply pointed back to text with the IP in it but some companies rejected those as being "generic". Early on we didn't care but more and more people do that so we finally put in PTRs that give the same name as the forward lookup.)

It might also require whoever does your firewall device setup to allow your sending server to send out over mail ports. As you might imagine that is typically NOT allowed so as to prevent random workstations from getting infected and becoming spambots. Once your domain is flagged as a spam sender the various sites that blacklist will list your entire domain and not just the IP that began spamming.

These days we do actually have a Sendmail server we relay to for one sending domain to separate its traffic from our main domain. Most of our email however, still relays via Office 365 instead using our main domain.

pcarlso7 10-05-2017 01:38 PM

Awesome, that makes sense. And also, fair enough. I appreciate the replies!


All times are GMT -5. The time now is 08:45 PM.