LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Using Mutt in Slackware 13 (https://www.linuxquestions.org/questions/slackware-14/using-mutt-in-slackware-13-a-4175424996/)

seflyer 08-31-2012 11:15 AM

Using Mutt in Slackware 13
 
I am working under Slackware 13. This evening I have been trying to write a shell script, in order to send emails (with some attached files) automatically everyday at, say, 8 o'clock.

The first thing, it seems to me, is to let the Mutt work. I googled and see answers like:
Code:

mutt -s "my subject" -a attachment-files somemail@gmail.com < email-content.txt
I tried this solution and several others, like
Code:

mail -s "Welcome" somemail@gmail.com
, with the above "somemail@gmail.com" substituted by my own gmail address. But then I receive no emails at all.

I think I might need to do something like creating and editing a .rc file. But as the task is a bit urgent, I would like to hear suggestions from experts while investigating the problem. Could anyone help me? Thanks in advance!

the3dfxdude 08-31-2012 02:10 PM

I have a working solution. I don't know if it is exactly what you are looking for. I will send it to you after I get off of work in about 5 hours.

the3dfxdude 08-31-2012 02:24 PM

Wait, do you have sendmail installed? If you send mails directly from your local machine (non-whitelisted address), you will likely need to whitelist or check your spam box. There is also an alternative to just login to your gmail account and send it to yourself.

I have a few minutes on to log into my server to check what I was doing.

This is perl code from my cron job, but the idea is open a pipe to mailx to feed the message to.
Code:

  if (!open($fh, "| mailx -s \"$subject\" $recipients")) {
    print "Error: Couldn't send email.\n";
    exit 0;
  }

I don't think you need mutt. I looked at it too, but couldn't figure it out.


If you want to send email using your gmail account with mailx, create this in $HOME/.mailrc
Code:

account gmail {
set folder=imaps://youremail@imap.gmail.com
set password-youremail@imap.gmail.com="yourpassword"
set record=+Sent
set from="Your Name <youremail@gmail.com>"
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=youremail@gmail.com
set smtp-auth-password="yourpassword"
}

Code:

  if (!open($fh, "| mailx -A gmail -s \"$subject\" $recipients")) {
    print "Error: Couldn't send email.\n";
    exit 0;
  }

So if you are using mailx make sure you have sendmail installed and running. Then make sure you clear your spam filter.

andrew.46 08-31-2012 09:45 PM

Perhaps you could adapt some of this guide, which does not deal with IMAP, to your needs:

http://www.andrews-corner.org/mutt.html

I believe it is even written by a Slackware user :).

seflyer 09-02-2012 07:58 AM

To the3dfsdude and andrew.46: thanks for your kind replies!

After struggling with sendmail for a while, it seems to be clear that to let sendmail work, the machine itself (which I am using now) should work like a mail server.

And that is complex... After some googling, I turned to mutt+msmtp combination and found them working well.

I put the very webpage that helped me out here, in case that anyone would come across similar problems:
http://www.viyin.net/2009/08/linux-m...kup-mysql.html
(it is a chinese webpage; but ignoring the few chinese characters seems not a problem to follow the whole process)

kjhambrick 09-03-2012 04:50 AM

Quote:

Originally Posted by seflyer (Post 4769303)
I am working under Slackware 13. This evening I have been trying to write a shell script, in order to send emails (with some attached files) automatically everyday at, say, 8 o'clock.

The first thing, it seems to me, is to let the Mutt work. I googled and see answers like:
Code:

mutt -s "my subject" -a attachment-files somemail@gmail.com < email-content.txt
I tried this solution and several others, like
Code:

mail -s "Welcome" somemail@gmail.com
, with the above "somemail@gmail.com" substituted by my own gmail address. But then I receive no emails at all.

I think I might need to do something like creating and editing a .rc file. But as the task is a bit urgent, I would like to hear suggestions from experts while investigating the problem. Could anyone help me? Thanks in advance!

seflyer --

Sometime in the 'recent' past, mutt changed it's syntax where if you invoke the -a Flag, a '--' flag is REQUIRED after the -a args but before the recipient list.

Try this ?

Code:

mutt -s "my subject" -a attachment-files -- somemail@gmail.com < email-content.txt  ### note -- flag after -a args
-- kjh

dive 09-03-2012 11:56 AM

You may find the mail or mailx command easier to use


All times are GMT -5. The time now is 07:51 PM.