April 27, 2010 at 7:06 am · Filed under Programming
Here is a great little tut on getting started in Bash. I’d recommend it to anyone trying to hack their way into a shell script.
Here is a quick script for sending an email:
#!/bin/bash
# Subject of email
SUBJECT="Test email with attachment from a bash script"
# Where to send it
TO_ADDRESS="your@email.com"
# Where the attachment is
ATTACHMENT_FILE="/tmp/attachment.txt"
# For fun, let's put something into the attachment
echo "This goes into the file." > $ATTACHMENT_FILE
echo "This appends to the file." >> $ATTACHMENT_FILE
# send the message
/bin/mail -s "$SUBJECT" "$TO_ADDRESS" < $ATTACHMENT_FILE |
March 31, 2009 at 12:27 am · Filed under Uncategorized
I got tired of ISPs blocking outgoing port 25, so I moved our SMTP for clients to port 587. Unfortunately, when migrating our new server, I couldn’t remember how to do this.
After some Googling, I found the answer; add this line inĀ /etc/postfix/master.cf, substituting your port number for 25000:
25000 inet n - n - - smtpd -o smtpd_sasl_auth_enable=yes |
I left port 25 on too, so users can try either from their ISP. If you want to turn off port 25, just comment out this line:
smtp inet n - n - - smtpd -o smtpd_sasl_auth_enable=yes |
Remember to open up the port in your server firewall as well!