Recently I wanted to add mail sending functionality to one of my scripts. This script runs on my desktop computer, so no fancy company mail servers/fixed IP/DNS records for me. When I googled it up I saw many different methods in varying complexity. My need was the simplest you can think of- just to send email. I didn’t care if it’s always from the same address. My solution was to use Ubuntu’s default exim4 mail server, with Gmail. Exim authenticates with your gmail user/password and the mail is always sent from the same address (email@example.com). This is heavily based on this, although a little different.
First I had to install exim4-config, so:
# sudo apt-get install exim4-config
Then I needed to configure exim to work with Gmail:
# sudo dpkg-reconfigure exim4-config
- General type of mail configuration: mail sent by smarthost; no local mail
- System mail name: localhost
- IP-address to listen: 127.0.0.1
- Other destinations for which mail is accepted: (leave blank)
- Visible domain name for local users: localhost
- IP address or host name of the outgoing smarthost: smtp.gmail.com::587
- Keep number of DNS-queries minimal: no
- Split configuration into small files: no
- Root and postmaster mail recipient: (leave blank)
Edit /etc/exim4/passwd.client (you can use gedit if you’re not comfortable with vi):
# sudo vi /etc/exim4/passwd.client
Add those lines (replace “user” and “password” with your own):
Finally update (refresh) exim configuration:
# sudo update-exim4.conf
That’s about it. To send the contents of /etc/motd as mail (just example):
# cat /etc/motd | mail -a “FROM: firstname.lastname@example.org” -a “BCC: email@example.com” -s “This is the subject” firstname.lastname@example.org
The “BCC:” is optional of course. If you don’t specify “FROM:” the default is the current user.
If you don’t have the “mail” command then just install mailutils:
# sudo apt-get install mailutils
My college, for some reason really likes Microsoft. All the workstations run windows, documents are always in office format, software development is done in visual studio, the website used to look normal in IE only, etc…
I expected computers science department to provide us students with alternatives, expose us to different platforms, but it didn’t happen. I’m on my last semester and “open source” was never mentioned in any class. I was disappointed when they forced me to use Visual Studio for operating systems class assignments. They got me pissed when they registered account for me (without permission), using my name at Microsoft Live@edu, but I got really mad when they announced that official emails would be sent to my new Live@edu address only.
Now, it might sound to you that I’m one of those Microsoft haters, but I’m not. I’ve nothing against them. I just happen to have favorite email service/operating system/office environment/development tools that aren’t Microsoft’s. I’m not angry because the products they force us students to use are Microsoft’s. I’m angry because they don’t let us choose. They keep us blindfolded in Microsoft’s realm. I guess they have good intentions, they do give the products for free. I agree that C# and .NET class should be studied with Microsoft Visual Studio. I can accept that most of the students feel comfortable with Windows operating system and the whole computing environment is Microsoft based. I can bear with the ActiveX and lack of Firefox support (used to be) on their website, but I won’t tolerate changing my email address, nor working with two different addresses. That’s bullshit. They have no reason getting that much into my personal life.
Therefor, like I always do, I found workaround using gmail with Live@edu account. I sent the administrators exact instructions, asking them to publish it, but they didn’t. So here are the instructions. I hope they’ll be useful for other students too.
From within Gmail:
Settings -> Accounts and import -> Add POP3 email acount
email address: email@example.com (replace with your username/academic institute mail server)
username: firstname.lastname@example.org (exactly the same as above)
pop server: outlook.com
Always use ssl
Enjoy using your Gmail :)