X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=xB xzZyPqUGaoErrwDeVWwNLhRKWhcuhZ3PK65iW6JFslBNK1/Iqj2gNZsJ0kKVpuvV UebWe7E+lyNZ9RAsRnFwMISt7XGGk/kH0/I08HXRJsQRqkfajZdo5S0zuRCtGpZQ dDNNKCh2bKZNKWBdjBLPEXgYDOd2ybF31j0GCJSUQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=123y4GWh wIT9Crg2MYd9UtAWQCw=; b=nzC/0F9ztmJjoElH5FRHX8ygpkNX5ERR4qDbWyH3 jJTPqDWdQTRT+2PJKKpqhv8I2urpLXFdhUEOszFEHMQMPs/90yd9SAnyCDF5p8mK 8BKaxjstGL+poCAbg+YkW7Ay55XpecrAdYcBcd+xy9pOIn/J7ofE89LPO/X4dEgv g2I= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f172.google.com MIME-Version: 1.0 X-Received: by 10.55.25.220 with SMTP id 89mr50618919qkz.40.1442498349851; Thu, 17 Sep 2015 06:59:09 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 Sep 2015 08:59:09 -0500 Message-ID: Subject: Re: Unable to send e-Mail from crontab in Cygwin From: Nem W Schlecht To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes On Wed, Sep 16, 2015 at 12:43 PM, Shantaraman,Karthik wrote: > Hi, > I have set up cygwin in my Windows Vista machine and have configured cron by > running the cygrunsrv command. > > I am trying to send an automated mail everyday with cron but it is not > working out. Could you help me with this? > > #Borrowed from anacron > SHELL=/bin/bash > PATH=/usr/sbin:/usr/bin > USER=karthik DOT techvs AT gmail DOT com > MAILTO="karthik DOT techvs AT gmail DOT com" > #End borrowed from anacron > > 15 10 * * * sendmail /USER=karthik DOT techvs AT gmail DOT com > "karthik DOT techvs AT gmail DOT com" testmail > > > I have installed the ssmtp package also after i researched about this > online. > > But it says : > > $ ssmtp-config > -bash: ssmtp-config: command not found This is, oddly, not very easily found/well documented when you do Google searches for 'cygwin cron sendmail'. cron on cygwin installs a symlink to /usr/bin/cronlog as /usr/sbin/sendmail on installation. This is a good thing. This script creates a file named 'cron.log' in your home directory for any cron command outputs. If you look at it, you'll notice many sendmail-like headers in the file. To have cron actually send emails, you need to set up /usr/sbin/sendmail as a link (or a program) to something that actually sends mails. I'm using msmtp, but I'm guessing ssmtp will be similar. Steps: 1) Remove the link /usr/sbin/sendmail 2) Create a new shell script or link in its place So: rm /usr/sbin/sendmail ln -s /usr/bin/msmtp /usr/sbin/sendmail (Note - use a decent editor instead of cat ... Control-D) I just installed 'msmtp' on a new install and ran 'msmtp-config'. If /usr/sbin/sendmail does *not* exist (ie, you install msmpt *before* cron) then it will create this link for you. Once you do all this, edit your crontab and put an entry in it like this: * * * * * date And reload (if you didn't do a 'crontab -e' to edit) It may take up to 2 minutes for cron to start doing stuff, as the minute in runs it'll load in the new crontab and then the *following* minute, it will run 'date' and should e-mail it to. Once you start getting e-mails, just comment this line out or delete it. -- Nem W Schlecht -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple