0

When I put the below command

echo "Subject: hello" | sendmail -v test@example.com < mail.txt

I get the email but with no subject.

Can someone let me know what must be done to get the subject as hello

Paz
  • 801
  • 1
  • 10
  • 14
  • when i just do echo "Subject: hello" | sendmail -v test@example.com I get the email with the subject line 'hello' but i need the body connect from the mail.txt – Bhavith Balakrishnan Oct 19 '21 at 06:56

1 Answers1

0

Seems like your ssmtp is not properly setup. I reproduced the error at my end and resolved the error as follows: Assuming that you already have mailutils installed. If not just enter the command

sudo apt-get install mailutils
  1. Start by installing the ssmtp
sudo apt-get install ssmpt
  1. Open the ssmpt config file using the following command
gedit admin:///etc/ssmtp/ssmtp.conf
  1. Enter the details as shown in the following config file. Make sure to fill in the x's , y's and z's with your own details. So replace x's by your email address, y's with your email ID password and z's with your hostname. You can find your hostname by just typing in "hostname" in your command line.
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mail
mailhub=smtp.gmail.com:587

AuthUser=xxxxx@gmail.com
AuthPass=yyyyyy
UseTLS=YES
UseSTARTTLS=Yes

# Where will the mail seem to come from?
#rewriteDomain=xxxxxx@gmail.com

# The full hostname
hostname=zzzzz

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES

Make sure to save your config file. Then run the sendmail command. You should be able to get a output sowing a lot more details on the command line rather than just a single line you are getting now.

Aamir Shah
  • 31
  • 7
  • when i just do echo "Subject: hello" | sendmail -v test@example.com I get the email with the subject line 'hello' but I need the body connect from the mail.txt The output I get when i run the command on the terminal is Mail Delivery Status Report will be mailed to Do u still need the smtp config details? – Bhavith Balakrishnan Oct 19 '21 at 14:51
  • okay so I have been able to reproduce the same error on my end. I have edited my answer, providing a step by step procedure to get the mail. – Aamir Shah Oct 19 '21 at 19:16