Schedule mail with attachment using Mutt

I have managed to schedule a bash script to backup several tables on an hourly basis. How can I send these tables as attachments, using the Schedule ? I've tried Bash with sendmail or mail or mailx - it seems these are not available or installed.

With Mutt which seems to be installed:

mutt -s “this is a test” -a /home/UserName/FileName.sql < /home/UserName/MsgBody.txt

I've tried with and without quotes and other variations... I get the following error again and again: sendmail: Cannot open mail:25 Error sending message, child exited 1 (). Could not send the message.

What shall I use to automatically send as an attachment to an email a couple of files ? Thanks

We don't provide an email service, so you'd need to configure mutt to talk to your email provider -- gmail or whoever it may be... You can also do the same thing with a Python library like smtplib or imapclient?

See the topic: Send mail with attachment on schedule using Web2Py

It worked for me and it is simpler than other solutions I found. The only caveat - the mail object should be defined in the Web2Py app in a model - which in my case was done already, since I needed it for sending mail to users for other reasons.


When you said that "We don't provide an email service" does that mean that we cannot send email from Python or PHP without using external SMTP providers?


Hi there,

It means that you can send an email "from python" if you already have an email account somewhere (eg: gmail), so that you can use the python smtp module (or bash sendmail, or mutt etc) to login to your gmail and then send an email.

But the key is that you need to have an email account somewhere, and pass in the account details to whatever program you are using to send emails.