Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sending cronjobs to gmail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Decibels
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1630
Location: U.S.A.

PostPosted: Tue Jan 07, 2014 2:33 am    Post subject: Sending cronjobs to gmail Reply with quote

Just got a webcam and was setting up Motion to monitor motion via the webcam. Got that working, but then wanted it to send the videos to my gmail account. But before could get that going got an fcron email and the To: was wrong. So got error from gmail, but it did get to me cause the From: was setup correctly. I successfully installed ssmtp with mailx. But mailx doesn't like sending mime very well, so unmerged it. Installed Mutt and that worked. But didn't want to keep getting fcron job errors.

What it was doing was adding my username to the email address like: username@decibels@gmail.com

Searched the net and didn't come up with a positive fix, but stumbled upon it. So will post here that might help others.

/etc/ssmtp/ssmtp.conf
Code:

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < MinUserId
# Make this empty to disable rewriting.
#changed from postmaster
root=decibels@gmail.com

# All mail delivered to userid >= MinUserId goes to user, not root.
#MinUserId=1000

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
#changed from mail
mailhub=smtp.gmail.com:587

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain       
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname

# Gentoo bug #47562
# Commenting the following line will force ssmtp to figure
# out the hostname itself.
#uncommented and changed from _HOSTNAME_
## had this and worked, but try below cause getting from cronjobs wrong: hostname=smtp.gmail.com:587
## might have to be: gmail.com
hostname=decibels@gmail.com

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
#FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
#UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/ssl/certs/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES

#Added these lines from here:http://www.gentoo-wiki.info/HOWTO_Gmail_and_sSMTP
#commented out ones done above. The uncommented weren't above
#root=youraccount@gmail.com
#mailhub=smtp.gmail.com:587
#rewriteDomain=
#hostname=smtp.gmail.com:587
UseSTARTTLS=YES
#added @gmail.com below, but might not need, may just need username
AuthUser=decibels@gmail.com
AuthPass=xxxxxxxx <add your password>
#optional
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES


From this it worked sending an email to gmail. But mailx didn't do what wanted so unmerged and installed Mutt. Mutt worked, but isn't necessary to discuss any further here cause didn't contribute or fix the frcon mail problem.

Fixing the username being added to the gmail account was pretty simple once setup above worked.
Just change MAILTO=useraccount@gmail.com

Code:
# fcron || dcron:
# This is NOT the system crontab! fcron and dcron do not support a system
#crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron or dcron do
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!!
# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org>

# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
MAILTO=decibels@gmail.com
55 19 1-31 1-12 0-7 /home/decibels/cron.weekly/gnucashbackup.cron
....
.... rest of frcontab


Now I get this:
Quote:
from: fcron <decibels@gmail.com>
to: decibels@gmail.com


And can move on to writing a script to email the videos from Motion.
Hope this helps anyone with this problem or if you just want to send cronjobs to your gmail account.
_________________
Support bacteria – they’re the only culture some people have.”

– Steven Wright
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum