Messaging
cancel
Showing results for 
Search instead for 
Did you mean: 

I want send mails form command line

Rogelio Cabrera
Frequent Advisor

I want send mails form command line

Hola.
I have a old server hp-9000 running hp-ux 11.0.
I want send mails from command line using command mailx or sendmail no matter.
I should check? and which command do you recommend?
On another server, with linux SO, I use:
#mail user@mail.com -s "Subject" < file.txt
I want something like the above for my hp-ux server

17 REPLIES
Patrick Wallek
Honored Contributor

Re: I want send mails form command line

Have you tried using mailx to send mail? Did it work? Check /var/adm/syslog/mail.log for errors.

On my systems:

mailx -s "Subject" user@mail.com < file.txt

works fine.

If the mail messages are not sent, then there may be sendmail configuration required. The entries from the mail.log file will help diagnose any problem encountered when sending mail.
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

Thanks Patrick.
Sent you my log file and I hope someone help me.
James R. Ferguson
Acclaimed Contributor

Re: I want send mails form command line

Hi:

From your mail log, it looks like you want to send mail to the external world. Configure the "smart relay" macro in '/etc/mail/sendmail.cf'. Make sure that your DNS works and you should be able to do:

# mailx -s "Hello!" root,rcabrera@ggp.com < /dev/null

The 'DS' macro should look something like this:

DSexchange.xyz.com

...where in this example, 'exchange.xyz.com' would be the name of my Exchange mail server.

Regards!

...JRF...
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

OK.
I edit the file and save it.
I need to restore some service?
James R. Ferguson
Acclaimed Contributor

Re: I want send mails form command line

Hi (again):

If 'sendmail' is running as a daemon, do:

# /sbin/init.d/sendmail stop
# /sbin/init.d/sendmail start

Otherwise, you shouldn't need to do this.

Regards!

...JRF...
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

Hi, Try sending again and
No, still not sent.
send the log file again.

#ps -ef | grep sendmail
root 4833 1 0 18:02:10 ? 0:00 sendmail: accepting connections
on port 25
#
Not knowing that this failing. :-(
Thanks.
Bill Hassell
Honored Contributor

Re: I want send mails form command line

The mail.log does not seem to show a mail relay server. Do you have a Microsoft Exchange system on your network? If true, then the DS line in sendmail.cf will show that server's name or IP address. If you do not have an Exchange (or Lotus Notes) server, then contact your Internet service provider to ask about their mail relay system.

You can see the mail transactions by using sendmail directly:

# /usr/sbin/sendmail -v bill@bill.com < /etc/issue

You will see the reason your mail is failing.


Bill Hassell, sysadmin
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

Thanks Bill.
I did as you indicated and got the following:
/#>/usr/sbin/sendmail -v rcabrera@ggp.com.mx < /etc/issue
/etc/mail/sendmail.cf: line 0: WARNING: writable directory /etc
/etc/mail/sendmail.cf: line 662: WARNING: writable directory /etc
/etc/mail/sendmail.cf: line 665: WARNING: writable directory /etc
WARNING: writable directory /var
WARNING: writable directory /etc
rcabrera@ggp.com.mx... ggp.com.mx: Name server timeout
rcabrera@ggp.com.mx... Transient parse error -- message queued for future delivery
rcabrera@ggp.com.mx... queued
WARNING: writable directory /etc

I have Microsoft Exchange Server 2007/64 in my network; her name is "mail.ggp.com.mx" and
on file "/etc/mail/sendmail.cf" I have the line: DSmail.ggp.com.mx
Is correct??
Regards :-)
Rita C Workman
Honored Contributor

Re: I want send mails form command line

I don't think 'your' email address is rcarbera@ggp.com.mx though.

So, also please adjust the DM line to say:
DMggp.com

See if that helps,
Rita
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

Thanks Rita for your help, but still the same. :-(
Tim Nelson
Honored Contributor

Re: I want send mails form command line

As mentioned fix all the errors spurned by sendmail first.


###>Thanks Bill.
I did as you indicated and got the following:
/#>/usr/sbin/sendmail -v rcabrera@ggp.com.mx < /etc/issue
/etc/mail/sendmail.cf: line 0: WARNING: writable directory /etc
/etc/mail/sendmail.cf: line 662: WARNING: writable directory /etc
/etc/mail/sendmail.cf: line 665: WARNING: writable directory /etc
WARNING: writable directory /var
WARNING: writable directory /etc
rcabrera@ggp.com.mx... ggp.com.mx: Name server timeout
rcabrera@ggp.com.mx... Transient parse error -- message queued for future delivery
rcabrera@ggp.com.mx... queued
WARNING: writable directory /etc


AND...
Then the basics. lookup the IP and the mx record for this ggp.com.mx ( this is a really weird domain name)

If you cannot even lookup the name how is it expect to do anything further ?

Do you have permission to forward/relay to this server, if it exists ? If the mail admin has not added you to their allowed list then how do you expect to relay through this host ?


Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

Hello Tim.
Only the file /etc/mail/sendmail.cf must be edited?
if I do:
#nslookup mail.ggp.com.mx
Using /etc/hosts on: Apolo
looking up FILES
Name: mail.ggp.com.mx
Address: 192.168.7.15
Aliases: .
#
I do not know if anything more to add some file!!!!!
for eaxample, from linux, i have no problems to send mails.
Bill Hassell
Honored Contributor

Re: I want send mails form command line

> WARNING: writable directory /var
> WARNING: writable directory /etc

These are very serious security problems that should be fixed. Someone with root capability has modified the directory permissions for /etc and /var. The correct permission should be 555, owned by bin:bin. If I saw this on a system, I would immediately run the command:

# swverify

then look at the number of problems reported by swverify. If /usr permissions are also compromised, I would pull the system off the network to protect any important data. I would then try to find out why these changes were made. If these were experiments to fix application problems, I would return all the permissions and ownerships (and missing directories, etc) back to normal with the command:

# swverify -F

Note that this may cause some non-HP programs to have problems and these should be resolved with the owner of the programs. Setting directories and files to 777 or files to 666 is a serious security error.

sendmail errors:
> rcabrera@ggp.com.mx... ggp.com.mx: Name server timeout

This means that your computer does not know how to resolve this hostname (ggp.com.mx). Until these commands return a valid IP address, your system cannot send email to this address directly. Run these commands to find the IP address:

# nsquery hosts ggp.com.mx
# nslookup ggp.com.mx

If no address can be found, your /etc/resolv.conf file and /etc/nsswitch.conf files need fixing.

> from linux, i have no problems to send mails

I am very sure your Linux system has a number of configuration differences that allow email to be sent. Run the same sendmail command I mentioned above:


sendmail -v rcabrera@ggp.com.mx < /etc/issue

Compare that to the HP-UX output.


Bill Hassell, sysadmin
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

hi Bill again, the files /etc/resolv.conf and /etc/nsswitch.con not exist on my server.
My mail server is: 192.168.7.15 and my dns server is 192.168.7.59.
Where should I put these values?
The 2 servers are on my LAN.
I think my case is complicated :-(
Thanks for your patience!!!
Bill Hassell
Honored Contributor

Re: I want send mails form command line

> files /etc/resolv.conf and /etc/nsswitch.con not exist on my server.

That is part of your problem. You have no DNS server configured.

My mail server is: 192.168.7.15 and my dns server is 192.168.7.59.
Where should I put these values?

Someone did not setup your system correctly. Your Linux box will have these values configured correctly. Ask your network administrator to tell you what your domain should be. Then create the DNS file /etc/resolv.conf with this entry:

domain whatever.com
nameserver 192.168.7.59

Then create /etc/nsswitch.conf with these entries:

passwd: files
group: files
hosts: files [NOTFOUND=continue UNAVAIL=continue] dns
networks: files
protocols: files
rpc: files
publickey: files
netgroup: files
automount: files
aliases: files
services: files

Now you should be able to resolve the hostname for your email address:

nslookup gpp.com.mx
nsquery hosts gpp.com.mx

Now fix /etc/sendmail.cf with the mail relay:

DS192.168.7.59

> I think my case is complicated :-(

Not really. You have several configurations that are missing. email depends on proper networking and that isn't correct right now. Once these step are done, run the sendmail -v again and paste the results for us to see.


Bill Hassell, sysadmin
Rogelio Cabrera
Frequent Advisor

Re: I want send mails form command line

I'll think of another option to meet this need.
I have seven years with this server, and until now we have this need to send mail.

Thanks for everything Bill and Good luck.
:-)
Steven E. Protter
Exalted Contributor

Re: I want send mails form command line

Shalom,

sendmail -v -a

This runs the sendmail queue runner, which can provide you diagnostics.

If you are relaying to an Exchange server, do not forget to set up relay for the HP-UX system. this is normally done 1 system at a time, explicitly by IP address.

As far as your original command mailx -s is the equivalent of your original post request.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com