Hi,
When no MTA is installed, How to send an email with a cronjob?
I have below entrty in my cronjob?
my /etc/cron.d/backup file looks like this.
MAILTO=myemail@example.com 15 11 * * * root /root/scripts/backup.sh
Can I send this email via SMTP server?
Hope to hear from you.
On Sun, Jul 21, 2013 at 2:12 PM, Indunil Jayasooriya indunil75@gmail.com wrote:
Hi,
When no MTA is installed, How to send an email with a cronjob?
Install postfix and configure to accept messages from 'localhost' only.
MAILTO=myemail@example.com
I guess you have a 'real' email id in your setup.
15 11 * * * root /root/scripts/backup.sh
Can I send this email via SMTP server?
Some global service providers may accept email from the postfix MTA in your server.
Alternately, you can configure postfix to relay the message via a 'smart_host' (preferred method). It will require you to provide a valid email address + plus password for your postfix (client) to do authenticate itself and send the outgoing message.
There is ample documentation on the 'Net to accomplish this.
-- Arun Khan
On Sun, Jul 21, 2013 at 02:12:55PM +0530, Indunil Jayasooriya wrote:
Hi,
When no MTA is installed, How to send an email with a cronjob?
I have below entrty in my cronjob?
my /etc/cron.d/backup file looks like this.
MAILTO=myemail@example.com 15 11 * * * root /root/scripts/backup.sh
Can I send this email via SMTP server?
Hope to hear from you.
There is a tool named SendEmail, which is a perl script that performs the sending side (not receiving) of SMTP email handling. It's straightforward to use via commandline, which is exactly what you would want to use from a cron job:
http://caspian.dotconf.net/menu/Software/SendEmail/
Am 21.07.2013 10:42, schrieb Indunil Jayasooriya:
Hi,
When no MTA is installed, How to send an email with a cronjob?
I have below entrty in my cronjob?
my /etc/cron.d/backup file looks like this.
MAILTO=myemail@example.com 15 11 * * * root /root/scripts/backup.sh
Can I send this email via SMTP server?
If you decide a full blown MTA is too heavy weight in your environment on the different nodes (Postfix isn't the ideal choice for a so called null client), then have a look at ssmtp for example. It is provided by EPEL
http://pkgs.org/centos-6-rhel-6/epel-x86_64/ssmtp-2.61-19.el6.x86_64.rpm.htm...
It does exactly what you intend to do.
There is another null client called msmtp
but that one isn't available being packaged for CentOS.
Hope to hear from you.
Alexander
On Sun, Jul 21, 2013 at 02:31:32PM +0200, Alexander Dalloz wrote:
If you decide a full blown MTA is too heavy weight in your environment on the different nodes (Postfix isn't the ideal choice for a so called null client), then have a look at ssmtp for example. It is provided by EPEL
http://pkgs.org/centos-6-rhel-6/epel-x86_64/ssmtp-2.61-19.el6.x86_64.rpm.htm...
If I remember correctly, this does require an outside host--that is, you have to use your ISP's mailserver as relay.
There is another null client called msmtp
but that one isn't available being packaged for CentOS.
That compiles very easily on CentOS, however. Again, not sure if it can be used without making use of your ISP's mail server.
I have an ancient page (slow site, not always up) on ssmtp, at http://www.scottro.net/qnd/qnd-ssmtp.html. It hasn't been maintained for awhile, there's a better page at the arch wiki.
https://wiki.archlinux.org/index.php/SSMTP
Am 21.07.2013 14:56, schrieb Scott Robbins:
On Sun, Jul 21, 2013 at 02:31:32PM +0200, Alexander Dalloz wrote:
If you decide a full blown MTA is too heavy weight in your environment on the different nodes (Postfix isn't the ideal choice for a so called null client), then have a look at ssmtp for example. It is provided by EPEL
http://pkgs.org/centos-6-rhel-6/epel-x86_64/ssmtp-2.61-19.el6.x86_64.rpm.htm...
If I remember correctly, this does require an outside host--that is, you have to use your ISP's mailserver as relay.
You are correct, a null client sends towards a central mailhub. That will be a properly configured MTA which does everything necessary to be compliant with current mail exchange standards.
There is another null client called msmtp
but that one isn't available being packaged for CentOS.
That compiles very easily on CentOS, however. Again, not sure if it can be used without making use of your ISP's mail server.
We are in a professional, enterprise environment I presume. Thus the self compilation approach is discouraged. Even if it is a small program which compiles easily. Unless you anyhow manage to maintain your own set of RPMs and your local yum repository.
I have an ancient page (slow site, not always up) on ssmtp, at http://www.scottro.net/qnd/qnd-ssmtp.html. It hasn't been maintained for awhile, there's a better page at the arch wiki.
Alexander
On Sun, Jul 21, 2013 at 03:19:33PM +0200, Alexander Dalloz wrote:
Am 21.07.2013 14:56, schrieb Scott Robbins:
On Sun, Jul 21, 2013 at 02:31:32PM +0200, Alexander Dalloz wrote:
There is another null client called msmtp
but that one isn't available being packaged for CentOS.
That compiles very easily on CentOS, however. Again, not sure if it can be used without making use of your ISP's mail server.
We are in a professional, enterprise environment I presume. Thus the self compilation approach is discouraged. Even if it is a small program which compiles easily. Unless you anyhow manage to maintain your own set of RPMs and your local yum repository.
Good point. I see an rpm for Fedora 17, but nothing earlier. I use it on a personal machine--professionally, I've never had the need for it.
On Sun, 21 Jul 2013 14:12:55 +0530 Indunil Jayasooriya wrote:
When no MTA is installed, How to send an email with a cronjob?
I personally use this:
http://www.cleancode.org/projects/email
You can get a Centos rpm for that from my webpage:
Centos 5: http://www.melvilletheatre.com/articles/el5/index.html
Centos 6: http://www.melvilletheatre.com/articles/el6/index.html
Note that the program isn't actually a mailserver.
On Sun, 21 Jul 2013 14:12:55 +0530
Indunil Jayasooriya wrote:
When no MTA is installed, How to send an email with a cronjob?
I usually do this:
import smtplib server = smtplib.SMTP('smtp.gmail.com:587') server.ehlo() server.starttls() server.ehlo() server.login('user@gmail.com', password) server.sendmail(from, to, message_
When no MTA is installed, How to send an email with a cronjob?
I usually do this:
import smtplib server = smtplib.SMTP('smtp.gmail.com:587') server.ehlo() server.starttls() server.ehlo() server.login('user@gmail.com', password) server.sendmail(from, to, message_
Hi larry,
I think your method is the easiest way.
I currently have below cronjob that sends the output to /tmp/backup.out file. it is OK.
35 13 * * * root /root/scripts/backup.sh > /tmp/backup.out 2>&1
How can I then send this /tmp/backup.out to an email address.
Here's the one I created
[root@host ~]# ls -al /root/send_email.py -rwxr-xr-x. 1 root root 382 2013-07-23 15:18 /root/send_email.py
[root@host ~]# cat /root/send_email.py #!/usr/bin/python
import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText
from_addr = 'root@host.example.com' to_addrs = ['myemail@gmail.com'] msg = open('/tmp/backup.out','r').read()
server = smtplib.SMTP('192.168.9.5', 25) server.sendmail("root@host.example.com", "myemail@gmail.com", msg) #server.sendmail(from_addr, to_addrs, msg)
Should I APPEND the PATH of the script (/root/send_email.py) to /root/scripts/backup.sh file. ?
I just ran this script (i.e - /root/send_email.py). It worked. I got the email. But no subject there. How can I add a subject called " CRON JOB OUTPUT " to the email receive .
Hope to hear from you.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 07/23/2013 03:07 AM, Indunil Jayasooriya wrote:
I think your method is the easiest way.
It almost certainly isn't easier than installing ssmtp. Everything that you'd have to to to get ssmtp to work you will also need to do to that python code, plus you have to manually send email for every job where you need it.
Should I APPEND the PATH of the script (/root/send_email.py) to /root/scripts/backup.sh file. ?
I just ran this script (i.e - /root/send_email.py). It worked. I got the email. But no subject there. How can I add a subject called " CRON JOB OUTPUT " to the email receive .
You're going to have to create your own RFC compliant headers. See how that's already more complicated than using ssmtp? (Cron already does that work if you install an MTA, such as ssmtp)
@ Indunil Jayasooriya
IIRC, in one of your follow up post, you mention that you have the Zimbra suite installed and running on *this* machine (which is why you might have had to remove the distro's default postfix in the first place).
If above is true then you should try to figure out how to send the cron emails using Zimbra's MTA (which BTW is also postfix).
Why are you trying to re-invent the wheel?
Am I missing something here?
On Jul 21, 2013, at 1:42 AM, Indunil Jayasooriya indunil75@gmail.com wrote:
Hi,
When no MTA is installed, How to send an email with a cronjob?
I have below entrty in my cronjob?
my /etc/cron.d/backup file looks like this.
MAILTO=myemail@example.com 15 11 * * * root /root/scripts/backup.sh
Can I send this email via SMTP server?
Hope to hear from you.
There is a nifty perl script which does this, and can even do attachments:
http://caspian.dotconf.net/menu/Software/SendEmail/
______________________________________________________________________ If life gives you lemons, keep them-- because hey.. free lemons. "♥ Sticker" fixer: http://microflush.org/stuff/stickers/heartFix.html