Forum OpenACS Q&A: Re: Sending Emails via SMTP port 587
Let me explain, what the following command does:
# version_ns=GIT build_dir=/usr/local/src/modules/nssmtpd ns_modules=”nssmtpd” bash install-ns.sh build
The command builds and installs NaviServer with its necessary environment (Tcl, etc.) with only the nssmtpd module.
In detail, the parameter mean:
version_ns=GIT
tells the script to use the very latest NaviServer version from the Git repository – essentially the “catch of the day”. The advice for beginners is to use the released versions (by omittingversion_ns
or by specifying a released version) unless you have a specific reason to use the latest unreleased version.build_dir=/usr/local/src/modules/nssmtpd
tells the script to use the specified directory as a place for all source files (such as TCL, NaviServer, TDOM, XOTcl, Tcllib, and other modules), where they are downloaded, extracted, compiled, etc. Only modify this if you need separate build trees (for instance, when working with different versions of Tcl like 8.5, 8.6, and 9).ns_modules="nssmtpd"
this restricts the build to include only the specified module - in this case, nssmtpd. By excluding the PostgreSQL module (which is normally included when PostgreSQL support is enabled), you risk breaking OpenACS unless you have previously built an installation with the same configuration/build tree.
We do not know where "[localhost]:25" is coming from.
This address is derived from your configuration file, specifically from the value of the relay
parameter. Here’s a breakdown of how the nssmtpd module integrates with OpenACS
Basic Architecture
The nssmtpd
module acts as an SMTP server that forwards all incoming mail to a “real” SMTP server defined by the relay
parameter in the module/nssmtpd
section of the configuration file
A OpenACS (Sender) → B (nssmptd, 127.0.0.1:smtpdport) → C (relay, localhost:25)
Workflow in an OpenACS Environment:
- A (OpenACS, the sender): Generates and sends the email.
- B (
nssmtpd
): Listens on the loopback address127.0.0.1
and the specifiedsmtpdport
, provides an API, and acts as an intermediary. - C (Relay SMTP Server): The actual SMTP server (commonly Postfix) that handles the final email delivery.
Default Configuration Assumptions:
- Specifying
smtpdport
in the NaviServer configuration file loads thenssmtpd
module, which then listens on the loopback interface at that port (B). - The actual SMTP server (C, typically Postfix) is expected to be running on
localhost
port 25. - OpenACS passes emails to
nssmtpd
using the API (actuallyns_smtpd send ...
), which then forwards the message to the real SMTP server for delivery.
Make sure you have a properly configured and working SMTP server on your system (like Postfix) that is set up to forward mail to your provider, or to send mail directly from your host. Since mail configurations can vary widely, using a well-supported mail server is generally the simplest approach. Provider usually offer configuration guidelines for this.
Bypassing the local mail server and using a different relay
in the nssmptd configuration instead of localhost:25
is possible when the target mail server allows this.
Hope, this helps,
-g