Results 1 to 11 of 11
Thread: send email with shell script
-
10-09-2013, 05:20 AM #1Newbie
- Join Date
- Oct 2013
- Location
- LA
- Posts
- 18
send email with shell script
this is shell script for send mail
it works well
but it gose to spem
i think becouse sender is "root@localhost.localhost"
how do i change sender ?
OS : centos 4.7 32bit
thank you.
function send_notification
{
if [ -s $PING_OUTFILE -a "$MAILOUT" = "TRUE" ];
then
case $UNAME in
AIX|HP-UX|Linux) SENDMAIL="/usr/sbin/sendmail"
;;
SunOS) SENDMAIL="/usr/lib/sendmail"
;;
esac
echo "\nSending e-mail notification"
$SENDMAIL -f root@$THISHOST $MAILLIST < $PING_OUTFILE
fi
}
-
10-09-2013, 05:24 AM #2Temporarily Suspended
- Join Date
- Aug 2013
- Posts
- 224
Are you running the server on localhost, or are you running it on a public domain/IP?
-
10-09-2013, 07:33 AM #3Junior Guru
- Join Date
- Feb 2012
- Posts
- 231
Login as a user and execute the script. It will send it as "user@....."
What is the MTA on your server ? Sendmail itself or EXIM/Postfix ?WEBUZO - Single User Control Panel for your VPS/Cloud/Server (CentOS/Ubuntu)
Install NGINX, Apache, MySQL, LAMP, LEMP, PHP, Java and 310+ popular scripts by a CLICK
Email Server, Database Management, Domain Management, FTP Management, CSF, CRON
-
10-09-2013, 09:20 AM #4Junior Guru
- Join Date
- Jun 2010
- Location
- Manchester, UK
- Posts
- 179
Agree with Valley.
As far as I know, you would need to login using the user account you wish to send the mail from.
I use Python for this type of thing nowadays, as it offers a wealth of options for just about whatever you want to code (i.e. SMTP authentication).█ Farbyte Ltd [UK] ♦ Professional UK Cloud Hosting ♦ Tel: +44 (0)843 532 0744
█ cPanel® web hosting since 2006.
█ Distributed Optane SSD caching cloud VPS
█ ♦ Hosting ♦ Domains ♦ SSL Certificates ♦ VPS
-
10-09-2013, 02:11 PM #5WHT Addict
- Join Date
- Apr 2011
- Location
- Charlotte, NC
- Posts
- 104
Why not just use the the 'mail' command?
http://linux.die.net/man/1/mailAdam Hahn
Software Engineer / System Administrator / Database Engineer
-
10-09-2013, 10:47 PM #6Web Hosting Master
- Join Date
- Mar 2005
- Location
- Ten1/0/2
- Posts
- 2,529
use mailx for sending email from a script - much easier and gives full access to set any/all headers as required including from address.
CPanel Shared and Reseller Hosting, OpenVZ VPS Hosting. West Coast (LA) Servers and Nodes
Running Linux since 1.0.8 Kernel!
Providing Internet Services since 1995 and Hosting Since 2004
-
10-10-2013, 03:07 AM #7Newbie
- Join Date
- Oct 2013
- Location
- LA
- Posts
- 18
Thank you
i will check it mailx function
thank you for helping me
-
10-13-2013, 03:21 PM #8Newbie
- Join Date
- Sep 2013
- Posts
- 10
You could also connect directly yo your relay server using telnet or nc, like
printf "helo aef\r\nmail from: <blah@blah.com>\r\nrcpt to: <foo@bar.com>\r\ndata\r\nsubject: test\r\n\r\ntest\r\n.\r\n" | nc mail.relay.foo.bar.com 25
-
12-19-2013, 03:02 PM #9Newbie
- Join Date
- Nov 2013
- Posts
- 13
This script you can use to send mails from shell working on Linux and FreeBSD
PHP Code:#! /bin/bash
TO_ADDRESS=”somebody@webhostingtalk.com”
FROM_ADDRESS=”me@webhostingtalk.com”
SUBJECT=”where i can find blueberries :)”
BODY=”I love coding”
echo ${BODY MESSAGE}| mail -s ${SUBJECT } ${TO_ADDRESS} — -r ${FROM_ADDRESS}
-
12-19-2013, 08:21 PM #10WHT Addict
- Join Date
- Oct 2013
- Posts
- 174
well you can change the username by running the script as a different user. "su - otheruser" But it looks like you are running the server locally... so it'll never go anywhere but on the local host
-
12-19-2013, 08:23 PM #11Web Hosting Master
- Join Date
- Mar 2005
- Location
- Ten1/0/2
- Posts
- 2,529
CPanel Shared and Reseller Hosting, OpenVZ VPS Hosting. West Coast (LA) Servers and Nodes
Running Linux since 1.0.8 Kernel!
Providing Internet Services since 1995 and Hosting Since 2004
Similar Threads
-
How to log RSYNC succes/failure in my shell file & send email notification
By mani_senti in forum Hosting Security and TechnologyReplies: 1Last Post: 05-02-2013, 05:02 PM -
Capturing shell script output to a variable then send it by email?
By ninety9 in forum Hosting Security and TechnologyReplies: 5Last Post: 08-17-2010, 01:05 PM -
Need help modifying shell script to email
By tnedator in forum Hosting Security and TechnologyReplies: 5Last Post: 05-22-2009, 12:38 AM -
Help needed on shell script to send mailqueue status.
By NightMan in forum Programming DiscussionReplies: 5Last Post: 03-03-2007, 05:41 AM -
mail script wont send email
By latheesan in forum Programming DiscussionReplies: 9Last Post: 12-13-2005, 05:04 PM