Archive

Posts Tagged ‘gmail’

Sending mail from command line

May 20, 2010 Leave a comment

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 (user@gmail.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

My selections:

  • 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):

gmail-smtp.l.google.com:user@gmail.com:password
*.google.com:user@gmail.com:password
smtp.gmail.com:user@gmail.com:password

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: user@gmail.com” -a “BCC: somemail@somedomain.com” -s “This is the subject” recipient@somedomain.com

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

Happy mailing!

Advertisements

We don’t need no Microsoft education

April 11, 2010 4 comments

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: john.doe@mail.mta.ac.il (replace with your username/academic institute mail server)
username: john.doe@mail.mta.ac.il (exactly the same as above)
password: user-password
pop server: outlook.com
port: 995
Always use ssl

Done.
Enjoy using your Gmail 🙂