You are not logged in.
Well, I have a problem, my ISP is blocking port 25 so I can't send any emails through that port.
So I thought maybe it would be possible to configure cron to send email messages using google's SMTP server but I don't know where to begin.
Ok, so is it possible or am I chasing a silly dream? Should I just write a shell script that sends email depending on the return code of a program instead of relaying on cron's ability to send emails?
Last edited by Nergar (2010-03-03 06:55:47)
Offline
You should instead probably configure your MUA (postfix, exim, msmtp, whatever) to send the mails through google's SMTP server. That way, anything on your machine that sends mails will automatically use it. The bad part is that you have to put your Google name and password in plain text in a config file.
Offline
Just a thought, has your ISP blocked port 465 which is secure SMTP?
Offline
mmm, no, I don't think so. I'll have to check
Offline
What kind of filthy ISP blocks ports like that?
Offline
Check also if they instead allow/use port 587 which is the submission port.
Google mail accepts connections on 25 and 587 (IIRC), so if they're both blocked by your ISP then no app will be able to send mail via gmail (or anyone else for that matter), unless I'm misunderstanding your post.
How do they expect you to send email?
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
You should instead probably configure your MUA (postfix, exim, msmtp, whatever) to send the mails through google's SMTP server. That way, anything on your machine that sends mails will automatically use it
//blue/0/~/ pacman -Q msmtp
msmtp 1.4.19-1
//blue/0/~/ cat .msmtprc
# msmtp config file
# gmail
account gmail
host smtp.gmail.com
port 587
protocol smtp
auth on
from pbrisbin@gmail.com
user pbrisbin@gmail.com
password XXXXX
tls on
tls_nocertcheck
# use gmail as default
account default : gmail
//blue/0/~/ cat .mailrc
set sendmail=/usr/bin/msmtp
but... as whom does cron run?
//github/
Offline
Well, the ISP is TELMEX, a Mexican ISP and it's only blocking port 25 as a counter measure for spam and computers infested with spambots. I also found out they will easily unblock that port if you call them and explain.
I have msmtp running and sending emails from standard input, now I need to know how to tell cron to use msmtp instead of whatever it is using. sendmail?
So, now I have two options;
The easy way out, call the ISP and get the port unblocked
Or the arch way, configure my system to behave exactly as I want
Offline
Look at the -M and -m flags for crond.
Offline
I still don't understand (probably my fault here).
What port is msmtp using now to send emails, and why do you need to use cron?
Why not just get your MUA to use msmtp directly?
EDIT: does this link answer your question?
http://www.debianhelp.org/node/4600
EDIT2: from the crond man page:
-M mailer
When cron jobs generate any stdout or stderr, it's formatted as a mail message and piped to /usr/sbin/sendmail -t -oem -i. Attempts to mail cron
output are also logged (regardless of whether they succeed). This switch permits the user to substitute a custom mail handler or script. It will
be called with no arguments, and with the mail headers and cron output supplied to stdin. When a custom mail handler is supplied, mailing is no
longer logged (have your mail handler do that if you want it). When cron jobs generate no stdout or stderr, nothing is sent to either sendmail or a
custom mail handler.
EDIT3: beaten to it. Should've checked before posting, after reading around.
Last edited by skanky (2010-03-02 23:00:56)
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
Well, the ISP is TELMEX, a Mexican ISP and it's only blocking port 25 as a counter measure for spam and computers infested with spambots. I also found out they will easily unblock that port if you call them and explain.
I have msmtp running and sending emails from standard input, now I need to know how to tell cron to use msmtp instead of whatever it is using. sendmail?
So, now I have two options;
The easy way out, call the ISP and get the port unblocked
Or the arch way, configure my system to behave exactly as I want
I vote the easy way as its quick and it's a service you pay your ISP for.
Offline
Well, the easy way out is fine, but I rather work a little harder and learn a few things in the process.
As soon as I get home I'll check that link and those flags.
Offline
well, i think cofiguring the -M switch in /etc/conf.d/crond should do the trick, thanx all for the help.
Offline
Easiest is to make /usr/sbin/sendmail a symlink to /usr/bin/msmtp. If you prefer not to, then you could add "-M /your/mail/handler/script" to the dcron invocation line in /etc/conf.d/crond. If you use the -M route, the mail handler script will be called without arguments. If you use the sendmail-is-a-symlink route, msmtp will be called with the default arguments "-t" "-oem" and "-i". msmtp ignores all of these but "-t", I'm not sure whether msmtp will work if dcron calls it without the "-t" argument. But if you try "-M /usr/bin/msmtp" and you find that not working, this is the reason. You'll need to either supply a wrapper script to -M that calls msmtp with the "-t" switch, or use the sendmail-is-a-symlink solution.
Offline
everyone seemed to miss this from my post:
//blue/0/~/ cat .mailrc
set sendmail=/usr/bin/msmtp
this makes my user's sendmail msmtp -- no symlink required.
now, my question is -- how to do it for cron? is /etc/mail.rc the same but system-wide? with fcron i just set the sendmail command in it's config so this is more of a curiosity then a call for help.
//github/
Offline
I have no idea about ~/.mailrc or /etc/mail.rc (and I'm the developer of dcron). dcron doesn't go around reading any user environment variables or dotfiles, in fact that's antithetical to its design. If you supply a -M handler, it calls it as the user in question, with no arguments and a formatted email as stdin. If you don't, it tries to call "/usr/sbin/sendmail -t -oem -i" as the user in question, with a formatted email as stdin. If the sendmail binary you have installed consults the user's .mailrc file and passes any input on to msmtp when it's configured as you described, then you may well be able to rely on that. But dcron's behavior is intentionally dumb, in the way I described.
Offline
If you don't, it tries to call "/usr/sbin/sendmail -t -oem -i" as the user in question.
i'm dumb. i was so busy trying to think of how to create /home/cron/.mailrc that i forgot that cron runs commands as the user who's crontab it's reading from. duh.
anyway, i just tested using the above command directly and it does not appear to respect my ~/.mailrc in anyway. i must've been confusing my setup for mailx as a more general sendmail override -- it was a long time ago.
i.e.
echo test | mail a@b.com # uses msmtp
echo test | sendmail a@b.com # does not
anyways, sorry for the misinformation and thanks for the clarification.
Last edited by brisbin33 (2010-03-04 18:47:31)
//github/
Offline