Monday, March 28, 2011

Sending a gmail message from the good old command line. Part 2

  • Alpine does not save passwords by default!!. So, it's necessary to enable such functionality in the configuration step before compilation

[sourcecode language="bash"]
./configure --with-local-password-cache-method --with-passfile=.alpinepwd

  • If you installed it before just do a "make uninstall", and then build it and install it again, you know the drill.

  • The configuration for using gmail is very straight forward:

and if that doesn't work you can try also:

In my case wouldn't work if I didn't include the port number.

  • In order to alpine to store your passwords you need to create a password file in your home folder:

[sourcecode language="bash"]
touch .alpinepwd
chmod 600 .alpinepwd

again, if that doesn't work ,try:

[sourcecode language="bash"]
touch .alpine-passfile
chmod 600 .alpine-passfile

  • You can see the syntax for sending a mail via the command line is rather complicated so I created an alias in my .bash_aliases

[sourcecode language="bash"]
alias mail='alpine -I"#,^M,^X,y"'

the application "mail" does exist but I don't have it installed.If you wish, copy it exactly this way, if you change anything won't work, of course you can call that alias whatever you like.

  • If you send a mail for the first time, it will ask you for your credentials, after you enter them, it will ask you whether you'd like it to store them in the disk.

  • The message you send is taken from a file, you can modify the script to create the file from one argument you give it.Here's the code:

[sourcecode language="bash"]
alpine -I"#,^M,^X,y" -subject "hello from command line" <message

where "message" is the file where you wrote the message. I'm not using my alias here as the script won't recognize it, I need to figure out why.

  • So now my real time application can call this script and send me an email if anything goes wrong, or maybe... just to say hello =-D.

  • Got a MB in my computer graphics project!

No comments:

Post a Comment