How to use Sendmail

 

Overview

The following describes various ways to create and send an email message with Sendmail.

What is Sendmail?

Sendmail is a mail transfer agent (MTA) used to route email to a specific recipient. It can be used by running the sendmail command in a Shell environment or within a programming script. For more information, see this page for a list of different parameters you can use with Sendmail.

Sendmail is subject to SMTP quota limits. DreamHost recommends that you configure any scripts relying on Sendmail to use SMTP authentication.

How to create a Sendmail message

The following explains two different options to create a Sendmail message.

In the following examples, you only need to adjust the highlighted text.

Option one — Using Sendmail from the command line

The following are two examples of how to send email from the command line using Sendmail.

Simple example

Log into your server via SSH. Once logged in, you can run the following command to send email:

[server]$ /usr/sbin/sendmail youremail@example.com
Subject: Test Send Mail
Hello World
control d (this key combination of control key and d will finish the email.)

The above example sends an email as follows:

  • The first line indicates the email address Sendmail will send the email TO. 
  • The Subject is Test Send Mail.
  • The body of the message is Hello World.
  • When the message is received, the FROM email address will appear as your user@server. For example, username@servername.dreamhost.com.

Option two — Using Sendmail in a script

You can also use Sendmail in a script as well. Consult the documentation for the programming language of your choice for examples.

When creating the file on a DreamHost server, make sure the permissions are set to 755, or it will not run.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?