-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_sendmail_gmail_relay
30 lines (23 loc) · 1.56 KB
/
install_sendmail_gmail_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 a gmail account as a relay for outgoing emails
read -p "press enter to continue"
echo what is your gmail email address?: ; read gmail_email_address
echo what is your gmail password?: ; read gmail_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:$gmail_email_address\" \"P:$gmail_password\" >> /etc/mail/authinfo/gmail-auth
makemap hash /etc/mail/authinfo/gmail-auth < /etc/mail/authinfo/gmail-auth
sed -i '/MAILER_DEFINITIONS/idefine(`SMART_HOST'\'',`[smtp.gmail.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/gmail-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 gmail relay" | mail -s "Sendmail gmail Relay" $recipient