Automatic email with attachment?
Patton Echols
p.echols at comcast.net
Sat May 29 17:47:12 UTC 2010
Hal Burgiss wrote:
> On Fri, May 28, 2010 at 7:46 PM, H.S. <hs.samix at gmail.com> wrote:
>
>> Patton Echols wrote:
>>
>>> I have a need to email files to various folks on a regular basis. I
>>> would like to automate the process. My idea is that a file would get
>>> dropped into a particular folder. Normally the folder would be empty.
>>> But when a file is dropped there, it is automatically attached to an
>>> email and sent to an email address.
>>>
>>> Does anyone know of a prebuilt utility that will do this? If I need to
>>> script it, does anyone have a script that they use for this purpose?
>>>
>>> I have a vague memory of something like this on the list, but I have
>>> been unable to construct a search that gets me anything.
>>>
>>> (The worse bit is I think I participated in the thread, and I STILL
>>> can't find it. Obviously I'm an idiot!)
>>>
>>> Thanks for aiding the hopeless
>>>
>
>
>> Here is one option:
>> http://www.cyberciti.biz/tips/sending-mail-with-attachment.html
>>
>> It should be easy to create a cron job that runs every periodically (few
>> minutes, half hour, whatever) to call a bash script that checks if a
>> particular directory has any file in it, if yes, then send that file as
>> an attachment and then to remove them.
>>
>
> You might could by without needing a script and do it all from within cron:
>
> */10 * * * * cd ~/attach ; [ -f attach.txt ] && echo "See attached"
> |mutt -s "Here ya go" -a attach.txt joe at example.com && rm attach.txt
>
> Note: not fully tested.
>
>
Interesting. I'll try that once the other parts are together. (Need to
configure sendmail on the server and ftp to put drop the files in the
first place) Should have been done by now but slightly more prosaic
hardware issues intervened.
Thanks for the suggestion.
--PE
More information about the ubuntu-users
mailing list