Operating System - HP-UX
1752795 Members
6103 Online
108789 Solutions
New Discussion юеВ

How to send email with attachment in a ksh script to an specific SMTP server.

 
Ton Swart
Occasional Contributor

How to send email with attachment in a ksh script to an specific SMTP server.

I've got the following:
uuencode xxx.dat xxx.dat | mail -s "Sending xxx.dat" a@b.com

But where do i specify the SMTP server adres?

I'm working on a server of our client, so I can't install third party mail client software.

Thanks in advance...

Ton Swart
4 REPLIES 4
RAC_1
Honored Contributor

Re: How to send email with attachment in a ksh script to an specific SMTP server.

The SMTP smart relay is defined in sendmail.cf file. (/etc/mail/sendmail.cf)

Define DS macro in sendmail.cf

Anil
There is no substitute to HARDWORK
Ton Swart
Occasional Contributor

Re: How to send email with attachment in a ksh script to an specific SMTP server.

Isn't there another way? So i don't have to do make any system changes? Like using another command.

Thanks for the fast reply... :D
RAC_1
Honored Contributor

Re: How to send email with attachment in a ksh script to an specific SMTP server.

telnet smtp_server_whatever_you_want 25.

Compose the email and sent. I do not know, how this will work and if ou will be able to attached files or not.

From unix side, I don't think that there is any option to put smtp server on command line.

Anil
There is no substitute to HARDWORK
Jeff_Traigle
Honored Contributor

Re: How to send email with attachment in a ksh script to an specific SMTP server.

Short of writing a perl script using an SMTP module, you can't as far as I know. The user agents all assume sendmail (or other MTA) is going to handle how the message gets routed to the destination. I used the perl approach for a couple of CGI projects I wrote a few years ago. (It also needed database access, which also couldn't be done from typical shell scripts.)
--
Jeff Traigle