Postfix commands

You can usually determine what mail transfer agent software is running on an email server by using Telnet to connect to the mail server on the Simple Mail Transfer Protocol (SMTP) port, port 25. E.g., in the example below Postfix is handling email on the system. 25% discount
# telnet 25
Connected to
Escape character is '^]'.
220 jinn.localdomain ESMTP Postfix
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 25
Connected to
Escape character is '^]'.
220 jinn.localdomain ESMTP Postfix
ehlo Me
250-SIZE 10240000
250 DSN
mail from:
250 2.1.0 Ok
rcpt to: joe
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
Subject: Just a test
This is only a test.
250 2.0.0 Ok: queued as B27928276DA1
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.

  1. You can enter a "helo" or "ehlo" command followed by whatever you like as a name - other email servers would typically provide their fully qualifed domain name (FQDN); I entered 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.
  2. You can then enter a 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".
  3. You can now specify a recipient email address with the 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, if joe was the user name for an account on the system, though I could also have entered, if joe was an account on the system and the system was processing email for the domain. The server should respond with another 240 code and "Ok", if it accepts email to the given recipient address.

    If a mail server accepts email for any email address then it is an open mail relay, which in most cases represents a serious security vulnerability. If the server is publicly accessible on port 25 and accepts email for any email address, then spammers will find it and use it to transmit spam to other servers, which will result in the server being added to blacklists, aka blocklists, maintained by companies and organizations seeking to combat spam.
  4. Next you enter the data command and hit enter. In the above example, Postfix responded with "354 End data with <CR><LF>.<CR><LF>"
  5. You can then type whatever you would like to have appear in the email message. When you are finished with the message, hit Enter and put just a period at the beginning of the next line and then hit Enter again. That will cause the MTA software to queue the message for delivery to the recipient's inbox.

    In the example above, I put the following lines after the data command:

    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.

  6. If you don't want to send any more messages, you can type 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

# 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


TechRabbit ad 300x250

Justdeals Daily Electronics Deals1x1 px