Dynamically using mail host


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamically using mail host
# 1  
Old 01-24-2011
Dynamically using mail host

Hi,

Can we dynamically using mail host to send mail in UNIX script if it is not configured on UNIX box?

Thanks,

Paventhan
# 2  
Old 01-24-2011
I really don't understand the question.

You have a UNIX box.
The UNIX box is NOT configured to send or receive mail.
You want to send mail from the UNIX box.

What does 'dynamically' mean here?

Both sendmail and postfix have "null client" configurations, where they do not run as a service, but will connect to an external mail relay host.

Additionally, programs and libraries exist (PHP, Perl, Python) to connect to a Mail server via SMTP.
# 3  
Old 01-25-2011
My UNIX box is not configured to send or receive mail using UNIX commands(sendmail or mailx). Now i call PERL mail module(which contains the mail host info) to send mails from unix script.

Can we define the mail host details in the UNIX script itself so it can use during every execution?
# 4  
Old 01-25-2011
You can with the Net::SMTP module. Net::SMTP - search.cpan.org
# 5  
Old 01-25-2011
You can set up the unix server by editing /etc/sendmail.cf (or similar) and finding the DS section. Un-comment the line to make it like the following:-
Code:
DSmyrelay.mycompany.com

This should be a mail router and should allow you to send stuff normally from any sendmail/mail/mailx command variation. You will also need to check that you can talk to the server on port 25 (smtp) Try the following:-
Code:
telnet myrelay.mycompany.com 25

You should get a connected message and wait on input. Typing quit should get you out. If you attempt pauses then times out after 30 seconds, there is a firewall blocking you or a routing problem. If it refuses you straight away, then it is not a mail relay.



I hope that this helps.

Robin
Liverpool/Blackburn
UK
# 6  
Old 01-25-2011
Currently i am using simple perl script with Mail::Sendmail module as a separate file and the mail host ip is hardcoded in the perl script. I just call this perl script where i need to trigger mail.

I want to know do we have any way to define the mail host in the shell script itself. So it can be used during every exceution to send mail.
# 7  
Old 01-25-2011
According to the CPAN documentation:
Quote:
The SMTP server has to be set manually in Sendmail.pm or in your script, unless you have a mail server on localhost.
So just modify Sendmail.pm with the default SMTP server. You'll see lines looking like this:
Code:
%mailcfg = (
    # List of SMTP servers:
    'smtp'    => [ qw( localhost ) ],
    #'smtp'    => [ qw( mail.mydomain.com ) ], # example

Simply change localhost to your network's mail/hub.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Need to recover/move diskgroup from failed host to another host

Hi All I am having VxVm on two Solaris hosts. host1 is using disk group dgHR. right now this server went down due to hardware fault. Not I need to import this dgHR into host2 server. Please let me know the procedure for the same. (1 Reply)
Discussion started by: amity
1 Replies

2. UNIX for Dummies Questions & Answers

No route to host - mail error

A linux box is supposed to emailing the results of backups to the windows exchange server, but nothing arrives. it never has, as the muppet who set up the Windows domain knew nothing about linux. I know only slightly more than that... pretty sure sendmail is the daemon running to handle mail. it... (0 Replies)
Discussion started by: Noewon
0 Replies

3. IP Networking

ping can not recognize host but host command can

Hi, I have a weird problem. when ever I do ping command like for example ping unix.comI get the following message: # ping unix.com ping: unknown host unix.com but when I use host the computer is able to know the host. # host unix.com unix.com has address 81.17.242.186 unix.com mail is... (2 Replies)
Discussion started by: programAngel
2 Replies

4. UNIX for Dummies Questions & Answers

Transfer large number of files host to host

Hello.... I have two servers, one has an empty / and the other has a subdirectory with a large number (4 gig) with many, many files. I need a way to transfer the files en masse from the server with the large number of files to the one that is essentially blank. I don't have space on the used... (16 Replies)
Discussion started by: blaine.miller
16 Replies

5. Solaris

Mail issue solution query- host map: lookup (domain): deferred

Hi all I had a mail issue earlier today where I was not receiving any emails from the servers of one of our clients. The mail queue just showed this: -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- o8S7eSpp020274* 5858 Tue Sep 28 10:42... (0 Replies)
Discussion started by: notreallyhere
0 Replies

6. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

7. Shell Programming and Scripting

running commands to remote host from centralized host

Gurus/Experts We have a centralized UNIX/Solaris server from where we can actually ssh to all other UNIX/Solaris servers...I need to write a script that reside on this centerlized server and do FileSystem monitoring (basically run df -h or -k) of other remote servers and then send an email to me... (6 Replies)
Discussion started by: anjum.suri
6 Replies

8. Solaris

How to delete the files from local host to remote host

Hi all, i am copying .gz files from production server to development server using "scp" command.my requirement is after copying .gz files i want to delete old .gz files(two days back) in development server from production server. like this way i need to delelte .log ,.z and .dmp files... (3 Replies)
Discussion started by: krishna176
3 Replies

9. IP Networking

mail host name on AIX box.

Hi, I was wondering if any body out there can tell me how can I find out what is the name of the mail host on the AIX box that I am working on? Is there any command to bring up the configuration for the mail server or mail host? Thanks in advance. (4 Replies)
Discussion started by: Shaz
4 Replies

10. IP Networking

QNX host cannot ping SCO host, vice versa

The problem I am facing now is that the QNX host could not ping the SCO host and vice versa. They are in the same domain, ie, 172.20.3.xx. As I am very new to Unix, I guess I must have missed out some important steps. Pls help... Thanx alot (2 Replies)
Discussion started by: gavon
2 Replies
Login or Register to Ask a Question