-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_sendmail_office365_relay
30 lines (23 loc) · 1.62 KB
/
install_sendmail_office365_relay
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
echo This will install sendmail and use an office365 account as a relay for outgoing emails
read -p "press enter to continue"
echo what is your office365 email address?: ; read office365_email_address
echo what is your office365 email password?: ; read office365_password
echo where should we send a test email?: ; read recipient
echo installing sendmail
apt install -y sendmail sasl2-bin mailutils sendmail-bin openssl
echo configuring sendmail
mkdir -m 700 /etc/mail/authinfo/
echo AuthInfo: \"U:root\" \"I:$office365_email_address\" \"P:$office365_password\" >> /etc/mail/authinfo/office365-auth
makemap hash /etc/mail/authinfo/ofice365-auth < /etc/mail/authinfo/office365-auth
sed -i '/MAILER_DEFINITIONS/idefine(`SMART_HOST'\'',`[smtp.office365.com]'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/idefine(`RELAY_MAILER_ARGS'\'', `TCP $h 587'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/idefine(`ESMTP_MAILER_ARGS'\'', `TCP $h 587'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/idefine(`confAUTH_OPTIONS'\'', `A p'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/iTRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/idefine(`confAUTH_MECHANISMS'\'', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN'\'')dnl' /etc/mail/sendmail.mc
sed -i '/MAILER_DEFINITIONS/iFEATURE(`authinfo'\'',`hash -o /etc/mail/authinfo/office365-auth.db'\'')dnl' /etc/mail/sendmail.mc
make -C /etc/mail
/etc/init.d/sendmail reload
echo sending test email
echo "Just testing my sendmail office365 relay" | mail -s "Sendmail office365 Relay" $recipient