Sendmail linux command line
Sendmail is a popular mail transfer agent (MTA) that is used to send and receive emails on Linux systems. Here are some common sendmail commands that can be used from the Linux command line:
Sending an email
sendmail -v [email protected]
: Send an email to the specified recipient using the default mailer.sendmail -t -i -f [email protected] [email protected]
: Send an email with a specified sender address and recipient address.sendmail -t -i -f [email protected] -c "Subject: Test email" [email protected]
: Send an email with a specified sender address, subject, and recipient address.
Options
-v
: Verbose mode, shows the email being sent.-t
: Read the email from standard input.-i
: Ignore dot (.) at the end of the line.-f
: Specify the sender address.-c
: Specify the subject of the email.-s
: Specify the SMTP server to use.
Example
Here is an example of sending an email using sendmail:
$ sendmail -t -i -f [email protected] -c "Subject: Test email" [email protected]
This command will send an email from [email protected]
to [email protected]
with the subject "Test email".
Configuring sendmail
sendmail -bi
: Rebuild the sendmail.cf configuration file.sendmail -bd
: Start the sendmail daemon in the background.sendmail -q
: Run the sendmail queue.
Troubleshooting
sendmail -bv [email protected]
: Verify the email address and check if it is valid.sendmail -d0.1
: Enable debugging mode and show the email being sent.
Note: The sendmail command is usually located in the /usr/sbin
directory, so you may need to use the full path to the command if it is not in your system's PATH. For example: /usr/sbin/sendmail -v [email protected]
.