Skip to main content
added 58 characters in body
Source Link
j77h
  • 21
  • 3

My server is CEntOS 7, and has sendmail but not mailx etc. Rather than install a new program I tested using sendmail directly, and found that this works:

echo -e "From: you@whatever\nTo: [email protected]\nSubject: this is the subject\n\nThis is the body,\nwith multiple lines." | sendmail -t 

For me this seems to be the simplest way to send a short email, as it does not require running or configuring a server or daemon, and can be done in a single command line.

The idea is that a message will simply alert me that a certain program threw an error, without revealing any potentially confidential info, and then I'll SSH to the server to inspect its logs. This way there's no need to bother with complications like attaching files or encrypting the transport.

Notes:

  • -e tells echo to interpret '\n' and other escapes.
  • -t tells sendmail to get recipient addresses from 'To:' in the message header.
  • If the mail does not arrive, use tail /var/log/maillogto see error messages.
  • If sending to your gmail address, make a filter at gmail to keep them out of the junk folder.
  • This sendmail is actually 'sendmail.postfix' (which might be normal); there's a man page here

The idea is that a message will simply alert me that a certain program threw an error, and then I'll SSH to the server to inspect its logs, so there's no need to bother with complications like attaching a file or encrypting the transport.

My server is CEntOS 7, and has sendmail but not mailx etc. Rather than install a new program I tested using sendmail directly, and found that this works:

echo -e "From: you@whatever\nTo: [email protected]\nSubject: this is the subject\n\nThis is the body,\nwith multiple lines." | sendmail -t 

For me this seems to be the simplest way to send a short email, as it does not require running or configuring a server or daemon, and can be done in a single command line.

Notes:

  • -e tells echo to interpret '\n' and other escapes.
  • -t tells sendmail to get recipient addresses from 'To:' in the message header.
  • If the mail does not arrive, use tail /var/log/maillogto see error messages.
  • If sending to your gmail address, make a filter at gmail to keep them out of the junk folder.
  • This sendmail is actually 'sendmail.postfix' (which might be normal); there's a man page here

The idea is that a message will simply alert me that a certain program threw an error, and then I'll SSH to the server to inspect its logs, so there's no need to bother with complications like attaching a file or encrypting the transport.

My server is CEntOS 7, and has sendmail but not mailx etc. Rather than install a new program I tested using sendmail directly, and found that this works:

echo -e "From: you@whatever\nTo: [email protected]\nSubject: this is the subject\n\nThis is the body,\nwith multiple lines." | sendmail -t 

For me this seems to be the simplest way to send a short email, as it does not require running or configuring a server or daemon, and can be done in a single command line.

The idea is that a message will simply alert me that a certain program threw an error, without revealing any potentially confidential info, and then I'll SSH to the server to inspect its logs. This way there's no need to bother with complications like attaching files or encrypting the transport.

Notes:

  • -e tells echo to interpret '\n' and other escapes.
  • -t tells sendmail to get recipient addresses from 'To:' in the message header.
  • If the mail does not arrive, use tail /var/log/maillogto see error messages.
  • If sending to your gmail address, make a filter at gmail to keep them out of the junk folder.
  • This sendmail is actually 'sendmail.postfix' (which might be normal); there's a man page here
Source Link
j77h
  • 21
  • 3

My server is CEntOS 7, and has sendmail but not mailx etc. Rather than install a new program I tested using sendmail directly, and found that this works:

echo -e "From: you@whatever\nTo: [email protected]\nSubject: this is the subject\n\nThis is the body,\nwith multiple lines." | sendmail -t 

For me this seems to be the simplest way to send a short email, as it does not require running or configuring a server or daemon, and can be done in a single command line.

Notes:

  • -e tells echo to interpret '\n' and other escapes.
  • -t tells sendmail to get recipient addresses from 'To:' in the message header.
  • If the mail does not arrive, use tail /var/log/maillogto see error messages.
  • If sending to your gmail address, make a filter at gmail to keep them out of the junk folder.
  • This sendmail is actually 'sendmail.postfix' (which might be normal); there's a man page here

The idea is that a message will simply alert me that a certain program threw an error, and then I'll SSH to the server to inspect its logs, so there's no need to bother with complications like attaching a file or encrypting the transport.