Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SMTP parameters and mailx

Status
Not open for further replies.

nivone

Programmer
Jul 2, 2002
33
IL
HI,

I'm working on an application that among other thing sends mails using mailx.
I've added SMTP support for this application with purpose to replace the use of mailx.
I want to spare the application users from entering the SMTP Server and Port parameters, and get these values during installation/upgrade.
Since they have used mailx up till now, I guess it is configured somewhere.
The reason that I want to get these parameters from the system is that this way the application will continue to work as before and the users will not even feel that it uses SMTP instead of mailx.

My questions are:
1. Where can I get these parameters from?
2. Is it possible that these parameters will reside on a machine other than the localhost (on which installation takes place)?
3. How many ways are there, to configure SMTP Server and Port for the use of mailx?
4. Did any of you ever confronted this issue? What would you suggest?

Thanks,

Nivo
 
Nivo, since everybody is using the mailx command, we'll assume that we'll not try to open up sendmail to outside IP addresses.

You seem to have a properly functioning mta (mail transfer agent) on your machine already, though it may not be a full mta. Find out what mail server is installed.
I say "find out what mail server" because many mta's provide a sendmail compatibility binary that emulates many of the basic commandline sending functions of the sendmail binary.

I straced the mailx command and it just calls /usr/sbin/sendmail and passes the message to it. Sendmail writes the temp file in /var/spool/clientmqueue, then figures out where it should send it to (if it's not local), tries to connect, and tries send it. If sendmail succeeds in sending the message, the temp file gets deleted. If sendmail fails in sending the message, the temp file gets converted to a queue file and a queue status file gets created (both in /var/spool/mqueue) and the temp file gets deleted.

If it turns out that sendmail is installed on your machines, I would just make sure that smtp is only listening on localhost and start it on each machine if it's not already started. Then in your webmail app or whatever this is for, just change it to use 127.0.0.1:25 instead of calling the mail program. If your app is php, it's well documented. If your app is perl, there are well documented mail modules. If your app is a c, you just open an inet socket to 127.0.0.1:25 and speak smtp. If your app is anything else, you'll have to figure it out.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top