# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 jinn.localdomain ESMTP Postfix quit 221 2.0.0 Bye Connection closed by foreign host. #
You can enter SMTP commands that other email servers would issue to send an email to a local user on the system as shown below:
# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 jinn.localdomain ESMTP Postfix ehlo Me 250-jinn.localdomain 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN mail from: tester@example.com 250 2.1.0 Ok rcpt to: joe 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> From: tester22@example.com To: joe@example.com Subject: Just a test This is only a test. . 250 2.0.0 Ok: queued as B27928276DA1 quit 221 2.0.0 Bye Connection closed by foreign host. $
After you connect to port 25, Postfix responds with
220 system_name ESMTP Postfix
. After the "220", which
indicates the SMTP service is ready, you will see the name of the system and
then "ESMTP Postfix". You can then take the following steps to send an email
message to an account on the system.
Me
in the example above. The MTA, in this case Postfix, responds with a 250 code
followed by its name and then subsequent 250 codes indicating the commands it
recognizes.
mail from:
command followed by an email
address. You can use whatever you like, even a nonexistent email address you
just made up at the moment. Unless there are some additional checks being made
by the system, the mail software doesn't know whether the address is legitimate
or not. You should then see another 250 response and "OK".
rcpt to:
command followed by an address. Unless the mail server is allowing
relaying, i.e., it will process email for accounts not on the system, this
will need to be an email address that is valid for that particular email
server, e.g., for an account on the system. If it is an account on the system,
just the account name may be sufficient. E.g., in the case above, I could
enter just joe
rather than a full email address such as
joe@example.com
, if joe was the user name for an account on the
system, though I could also have entered joe@example.com, if joe was an
account on the system and the system was processing email for the example.com
domain. The server should respond with another 240 code and "Ok", if it accepts
email to the given recipient address.data
command and hit enter. In the above
example, Postfix responded with "354 End data with
<CR><LF>.<CR><LF>"
In the example above, I put the following lines after the data
command:
From: tester22@example.com
To: joe@example.com
Subject: Just a test
This is only a test.
.
I could have omitted the "From", "To", and "Subject" lines and Postfix or
another MTA, such as Sendmail, will queue the message for delivery. I put those
lines in there for the user's email client software, such as
Microsoft Outlook,
Thunderbird, etc. An email client will use those lines for its display
of a "From", "To", and "Subject" line. As you may note, I put a different
"From" email address than the one I used with the mail from
command. They don't have to match; an MTA, such as Postfix or Sendmail,
is just treating the lines that follow the data
command
as data for the email client and typically doesn't care whether those two
addresses match. This is why you can never rely on the "From" address in
email messages that you see to reflect the true sender of a message. Spammers
often use fake email addresses on such "From:" lines or may use a real
email address belonging to someone else. Likewise, the
To:
line doesn't have to match the rcpt to:
email address.
When you've finished the message and put a period at the beginning of a line and hit Enter, you should see another 250 response code and an indication that the message has been queued for delivery.
quit
to terminate the connection to the MTA, i.e., Postfix in this case.
The above SMTP commands are ones you can enter with any MTA, such as Postfix or Sendmail, to send email. If you have root access on the system on which Postfix is running there are Postfix commands that you can enter at a command line interface (CLI), i.e. a shell prompt to obtain information or perform checks.
You can check on whether the software is running on a system and obtain
the process
identifier (PID) for the process running the program, if it is running,
using the Postfix command postfix status
# postfix status postfix/postfix-script: the Postfix mail system is running: PID: 1938 #
You can start and stop the Postfix software with postfix start
and postfix stop
. You can check on bad file ownership or
permissions and create missing directories with postfix check
. If
all is ok, you shouldn't see any output.
# postfix check #
If you have root access to the system, you can also use the
postconf command for
various Postfix-related functions. E.g., the version of the Postfix mail
software running on a system can be checked with the postconf
mail_version
command.
# postconf mail_version mail_version = 2.10.1 #
You can see the default values Postfix is using by issuing the command
postconf -d
. You will be presented with a large amount of output
for its configuration. I've shown some of the output from a system running
Postfix below, but snipped about 700 lines of output.
# postconf -d 2bounce_notice_recipient = postmaster access_map_defer_code = 450 access_map_reject_code = 554 address_verify_cache_cleanup_interval = 12h address_verify_default_transport = $default_transport address_verify_local_transport = $local_transport address_verify_map = btree:$data_directory/verify_cache address_verify_negative_cache = yes address_verify_negative_expire_time = 3d address_verify_negative_refresh_time = 3h address_verify_poll_count = ${stress?1}${stress:3} address_verify_poll_delay = 3s address_verify_positive_expire_time = 31d address_verify_positive_refresh_time = 7d address_verify_relay_transport = $relay_transport address_verify_relayhost = $relayhost address_verify_sender = $double_bounce_sender <text snipped> virtual_mailbox_limit = 51200000 virtual_mailbox_lock = fcntl, dotlock virtual_mailbox_maps = virtual_minimum_delivery_slots = $default_minimum_delivery_slots virtual_minimum_uid = 100 virtual_recipient_limit = $default_recipient_limit virtual_recipient_refill_delay = $default_recipient_refill_delay virtual_recipient_refill_limit = $default_recipient_refill_limit virtual_transport = virtual virtual_uid_maps = #
You can see a much shorter amount of configuration data with
postconf -n
which shows only configuration parameters that have
explicit name=value settings in main.cf.
# postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_ directory/$process_name $process_id & sleep 5 html_directory = no inet_interfaces = localhost inet_protocols = all mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = $myhostname, localhost.$mydomain, localhost newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES sample_directory = /usr/share/doc/postfix-2.10.1/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop unknown_local_recipient_reject_code = 550 #