run Evolution from the command line

Asked by Brent Creech

evolution mailto:<email address hidden>
Starts Evolution and begins composing a message to the e-mail address listed.
I was curious if there is a way to finish writing the mail message from the command line, or have your script jump to the GUI and fill in the two major fields that are left empty (subject, Text Body) and then send it ctrl return?

 Step #1
Need to add a subject:
evolution mailto:<email address hidden>?subject=Test

%20 = space
%0D%0A = line breaks

 Step #2
Add the text to the body of the email:
evolution mailto:<email address hidden>?subject=Test\&body=Some%20cr azy%20story%20stuff

 Step #3
Next step will be to send the message that we created:
%11%0D = ctrl return -> Doesn't work still looking for the correct solution
evolution mailto:<email address hidden>?subject=Test\&body=Some%20cr azy%20story%20stuff

http://ubuntuforums.org/showthread.php?p=3711420#post3711420

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu evolution Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Clóvis Fabrício (nosklo) said :
#1

I think there should be no way to send a mail through a link.
That would be a major security issue.

Revision history for this message
Brent Creech (brentcreech) said :
#2

In the sense that ClovisFabricio set it up I would agree that a link in a web page or document that sent off an email just by clicking on it would be a bad idea.
However there is a better use of it. How about a cron job that emails out reminders to a group: i.e. birthday reminders sent to family, bill reminders to myself or roommates, appointment reminders for myself, girlfriend, kids, etc. In this sense having user interaction would defeat the advantages of setting up a cron job. Also getting such a script to run with evolution the default mail program would help insure compatibility unlike my last upgrade from Fiesty to Gutsy where I had evolution and mail (for command line emailing) and during the upgrade there was an error with the mail which aborted the upgrade before finishing leaving my system in a very unstable state which I repaired by clearing the HD and reloading Ubuntu. I would like to protect myself so that in April I don't have the same experience when I upgrade again.

From all the help documents I've read this appears to be the only way someone could generate email from evolution on the command line only. Please correct me if I'm wrong. Or if there is a better solution. I've had no hits on my forum thread.

Revision history for this message
Clóvis Fabrício (nosklo) said :
#3

Evolution isn't designed to send mail on background. It is a foreground GUI program.
I guess this type of mail-sending script in background isn't one of their planned features.

I also believe that sending reminders is somewhat consistent with evolution's calendar reminder. Not with some command line script. You should set the appointment in evolution itself and have it send the mail, without using command line stuff. I don't know if it is already possible.

I guess the command line option of evolution is for handling links only.

You can reach evolution developers in many ways here:
http://www.gnome.org/projects/evolution/developer.shtml
Maybe you should join their meeting and suggest the feature.

For sending command line mail, there are plenty of options. And writing a simple script in python, lua, perl, etc to send SMTP mail is even easier. I don't see much good in evolution supporting this via command line.

as an example, in python:
http://docs.python.org/lib/SMTP-example.html

Revision history for this message
R. Drew Davis (drewclist) said :
#4

Doing it with a Python program strikes me as overkill. The Python program is invoking SMTPlib to send the mail, so might as well get SMTP working in postfix by following the instructions in https://help.ubuntu.com/community/Postfix to fix up /etc/postfix/main.cf. Then "sudo apt-get install mailutils" to install the good old command-line "mail" command. The documentation for "mail" is on http://www.gnu.org/software/mailutils/manual/html_node/mail.html.

I pumped out my mail by setting up a file (/tmp/party) with a line for each of the mailing addresses, and another file with my message (/tmp/msg). Then I used this command line to send the mail:

xargs -n 1 --arg-file=/tmp/party -d \\n mail -s "Party at Harvest Diner, Saturday 11/20" </tmp/msg

The string after the -s is the subject line for the outgoing messages. Oh, and I did set up .mailrc in my home directory
to have:

set noaskcc

after setting up the standard default /etc/mail.rc per the instructions. An example file that you can copy is in /usr/share/doc/mailutils/examples after you install mailutils.

Trickiest part for me is that my ISP (optimumonline.net) blocks attempts to SMTP directly to my mail server, so I had to set up my ISP's SMTP server as a relay host in /etc/postfix/main.cf. The one part of this that I don't quite understand is that I never did set up the stuff I believe is needed to do authentication with the ISP's SMTP server. I stopped fixing things when it started working. I speculate that Evolution hokes up suitable certificates and that postfix is just using those cert's to its sending. I didn't do anything to confirm that theory and would welcome any more informed explanation.

By mistake, I left the -n 1 off of the command line when I sent my party invitations out. That caused the mail to get sent to multiple addresses per message. The reason it is better to include the -n 1 is that when you send the mail out to multiple people per message:

1- You are unnecessarily exposing people's e-mail addresses to "others" that they don't necessarily want to share with.

2- You may have to read bounce messages more closely to figure out which addresses didn't work.

3- People replying to their message may send the reply to everyone mentioned in the e-mail they received instead of just replying to you.

The -n 1 causes each outgoing message to go just go to a single line in the file of addresses.

One typing detail that I worry about as I enter this answer is that the -d on the xargs command line has -d, a space, 2 backslashes and an n to cause xargs to parse the list of addresses into newline delimited lines. If you don't see 2 backslashes in the example, the web ate them. I tried it with one slash during my testing, but that caused xargs to use the letter n as a separator. Oops. 2 backslashed made it work. That kind of caught me by surprise.

Can you help with this problem?

Provide an answer of your own, or ask Brent Creech for more information if necessary.

To post a message you must log in.