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?
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@mydomain.com\n" exp_continue } -re "250.*ender" { exp_send "rcpt to:<recipient@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" } }