[CentOS] When no MTA is installed, How to send an email with a cronjob?
Ben Mohilef
benm at dsl-only.netSun Jul 21 18:49:36 UTC 2013
- Previous message: [CentOS] Fwd: When no MTA is installed, How to send an email with a cronjob?
- Next message: [CentOS] When no MTA is installed, How to send an email with a cronjob?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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 at example.com > 15 11 * * * root /root/scripts/backup.sh > > Can I send this email via SMTP server? > The following script works for us to send notifications to a mobile "server" that can not process very long text messages. Unless you have perfect control over who is allowed to use this script and what is being sent, it is VERY bad security practice. Replace the bracketed setup stuff (inside <> ) with the appropriate sources and destinations. "$argv" passess the raw data to be transmitted. Depending on what's in the message, you may have to modify the 3rd through 6th lines. YMMV. > #!/usr/bin/expect > > set idx [string first \{ $argv] > set argv [string replace $argv $idx $idx] > set idx [string last } $argv] > set argv [string replace $argv $idx $idx] > > spawn telnet <destination> 25 > set send_slow {1 .01} > set timeout 180 > > expect { > -re "Escape character is" { > exp_send -s "helo <destination_domainname >\n" > exp_continue > } > -re "220" { > exp_send -s "mail from: <me at mydomain.com>\n" > exp_continue > } > -re "250.*ender" { > exp_send "rcpt to:<recipient at destination_domainname>\n" > exp_continue > } > -re "250.*ecipient" { > exp_send -s "data\n" > exp_continue > } > -re "354" { > exp_send -s "Subject: <Subject>\n\n" > exp_send -s "$argv\n" > exp_send -s ".\n" > puts "sending\n" > exp_continue > } > -re "Message" { > exp_send -s "quit\n" > } > -re "221" { > puts "done\n" > } > }
- Previous message: [CentOS] Fwd: When no MTA is installed, How to send an email with a cronjob?
- Next message: [CentOS] When no MTA is installed, How to send an email with a cronjob?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list