LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2015, 01:46 AM   #1
cli
Member
 
Registered: Apr 2013
Distribution: RedHat, Cent, Ubuntu
Posts: 80

Rep: Reputation: Disabled
sending mails with port number 587 bash script help


Hi All,
We have some shell scripts which will send emails about backup, alerts etc using mail command. Example.
Code:
echo "Test Mail" | mail -s "Test" me@mydomain.com
I guess the above command just connect port number 25 of our mail server even if we do not define any port number. Now I would like add smtp port number as 587 in all of the bash scripts. I googled for this but could not get whatever I am expecting. So expecting your kind reply to define smtp port number as 587 in all of the bash scripts.

Thanks in advance.
 
Old 03-23-2015, 02:11 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,850
Blog Entries: 36

Rep: Reputation: 455Reputation: 455Reputation: 455Reputation: 455Reputation: 455
I send mail over 587. In /etc/mail/sendmail.mc I have the following lines.

Code:
define(`RELAY_MAILER_ARGS', `TCP $h 587')                                                                        define(`ESMTP_MAILER_ARGS', `TCP $h 587')
I generate /etc/mail/sendmail.cf from the mc file. However, I'm also authenticating with the SMTP server over 587. What exactly are you trying to accomplish?
 
1 members found this post helpful.
Old 03-23-2015, 03:05 AM   #3
cli
Member
 
Registered: Apr 2013
Distribution: RedHat, Cent, Ubuntu
Posts: 80

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.
Where should I edit this i.e the /etc/mail/sendmail.mc is from our mail server or any local PC/Laptops where shell script will be running.
I just wanted to define smtp settings only in each shell scripts of our local servers because one of our public IP itself has been blacklisted and not able send mails to our mail server with shell scripts because of rbl enabled in our mail server. But we have made sure that our local servers can send mails with port 587 with gerrit service after changing the port number to 587 in gerrit configuration file. But not able to send mails with shell scripts which still may be trying to connect default port 25 of our mail server and getting deny error. So expecting your kind help to define the smpt port number in each bash shell scripts rather than editing the global configuration files of our local servers as few are using sendmail and few servers are using postfix.

Last edited by cli; 03-23-2015 at 03:08 AM.
 
Old 03-23-2015, 09:18 PM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,850
Blog Entries: 36

Rep: Reputation: 455Reputation: 455Reputation: 455Reputation: 455Reputation: 455
Quote:
Originally Posted by cli View Post
Where should I edit this i.e the /etc/mail/sendmail.mc is from our mail server or any local PC/Laptops where shell script will be running.
It would be on the client machine doing the sending of the email. I spent 5 minutes reading the mail man page searching for the string "port". There's an smtp string option that can be defined as...

Code:
echo "Test mail" | mail -S smtp=smtps://server:port -s "Test" me@mydomain.com
If it were me I'd want to edit the config global config files rather than a script hack. The same fix (from my first post) is not for both sendmail and postfix. Fix it for the appropriate software you have installed on the server needing to send the mail. That would be my recommendation. That and look to man pages.

Last edited by sag47; 03-23-2015 at 10:21 PM.
 
Old 03-23-2015, 10:56 PM   #5
thegwer
Member
 
Registered: Jan 2012
Location: San Antonio. TX
Distribution: CentOS. Ubuntu
Posts: 48

Rep: Reputation: Disabled
Even if your IPs have been blacklisted to the world you should still be able to have control over your own mailserver to White list them.
What mailserver or MTA are you running?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Evolution not sending E-Mails Rockgod1969 Linux - Software 1 01-07-2009 04:34 AM
Qmail is not sending mails sajith Linux - Networking 1 12-16-2008 09:30 PM
Sending mails sanjibgupta Linux - General 1 06-08-2006 06:40 PM
Sending e-mails via a C++ program The_Nerd Programming 6 12-05-2004 10:56 PM
qmail not sending mails spank Linux - Software 0 05-21-2004 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration