iMarket Digital Properties

0 %
iMarket Digital Properties Ltd
Design · Develop · Monetize · Support
  • Location:
    United Kingdom
  • City:
    London
  • Service Area:
    Global
Business Systems
Business Services
24/7 Support
Websites
Web Applications
E-commerce Solutions
Digital Platforms
Products & Services
Public & Private Networks

How To Install And Configure Sendmail On Ubuntu

January 4, 2018
https://gist.github.com/adamstac/7462202https://www.abeautifulsite.net/configuring-sendmail-on-ubuntu-1404

1. Install Sendmail

$ sudo apt-get install sendmail

2. Configure /etc/hosts file:

Find your hostname by typing:
$ hostname
Then:
$ sudo nano /etc/hosts
On the line starting with 127.0.0.1, add the hostname to the end so it looks the same as:
127.0.0.1 localhost hostname
(You willl notice that your hostname can also be identified on the line that starts with 127.0.1.1 where it appears twice)Ctrl+x, then ‘Y’ to save and exit.

3. Run Sendmail’s config and answer ‘Y’ to everything:

$ sudo sendmailconfig

4. Restart Apache

$ sudo service apache2 restart

5. Using sendmail:

To quickly send an email:
$ sendmail -v [email protected]
After hitting the enter key, on the line directly below, enter a From address (each line after you hit enter will be blank):
From: [email protected]
Hit enter again and type a subject:
Subject: This is the subject field of the email
Hit enter again and type the message:
This is the message to be sent.
Hit enter again. To send the email, type a ‘.‘ (period/dot) on the empty line and press enter:
.
Wait a few seconds and you will see the output of the email being sent. To see more usage examples, check out the links below.https://www.computerhope.com/unix/usendmai.htm https://clients.javapipe.com/knowledgebase/132/How-to-Test-Sendmail-From-Command-Line-on-Linux.html https://help.dreamhost.com/hc/en-us/articles/216687518-How-do-I-use-Sendmail-

ERRORS & SOLUTIONS

If you can not send mail.When sending emails from your server, make sure to check any spam folders for receipt. If email is for some reason not working, try the steps below (modify the php version below as necessary):
$ sudo nano /etc/php/7.0/fpm/php.ini
Ctrl+w to search for and find ‘sendmail_path’. Uncomment this line and add the path below:
sendmail_path= /usr/sbin/sendmail -t -i
Restart php:
$ sudo service php7.0-fpm restart

Hosting

Develop and scale your apps globally with DigitalOcean and/or Vultr – or use shared hosting with no server maintenance required at iMarketHost.com.

Installation & Maintenance

If you would like to get this app installed, maintained or need training, Contact Me to get current rates.
Posted in TutorialsTags:
27 Comments
  • tarek

    I don’t get this one bit, what does local host have anything to do with send mail.

    I can send mail via echo “My test email being sent from sendmail” | /usr/sbin/sendmail [email protected] but how do I configure sendmail to always use [email protected]

    11:43 pm January 7, 2020 Reply
    • Hello, localhost is your server which sendmail uses to send the email. The post has been updated to reflect a basic usage example that includes a ‘From’ field. To configure sendmail to always use a specific email address, check out this link at https://clients.javapipe.com/knowledgebase/132/How-to-Test-Sendmail-From-Command-Line-on-Linux.html where you would create a template file, for example:

      $ cd ~
      $ sudo nano mail.txt

      with some content like:

      To: [email protected]
      Subject: sendmail test
      From: [email protected]
      
      And here goes the e-mail body, test test test..

      and send email with:

      $ sendmail -vt < ~/mail.txt
      10:49 am January 8, 2020 Reply
      • Thank You very much. Very good instructions, now sendmail on my server works correctly.

        Best regards from Germany

        7:17 am September 30, 2021 Reply
      • Poonam Dixit

        Thank you so much . its really works me

        5:38 am November 17, 2021 Reply
  • Chaimaa Moutachaouiq

    How should I veirfy that the sendmail configuration is well done?

    1:41 pm June 27, 2020 Reply
    • Just test it from the command line using the lines of code above to send an email.

      8:55 am June 29, 2020 Reply
  • Colin Parkinson

    Hi all – I’ve always had trouble with sendmail – but I thought I would try again with a new server
    When you config it you are supposed to say ‘Y’ to everything – there no option to to add/change parameters.
    Hence I get ‘connection timed out’ message – In NZ port 25 is not allowed .
    Question – were is the parameters file to change sendmail configuration.
    Much appreciated.

    10:38 pm July 29, 2020 Reply
  • Akshay Kshirsagar

    Hi,

    I am not able to send a mail, can you please help me out ?

    root@test:/etc/mail# sendmail -v [email protected]
    Subject: Test
    This is test mail
    .
    [email protected]… Connecting to [127.0.0.1] via relay…
    220 localhost.localdomain ESMTP Sendmail 8.15.2/8.15.2/Debian-10; Mon, 24 Aug 2020 06:29:45 GMT; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
    >>> EHLO localhost.localdomain
    250-localhost.localdomain Hello localhost [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-EXPN
    250-VERB
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH DIGEST-MD5 CRAM-MD5
    250-STARTTLS
    250-DELIVERBY
    250 HELP
    >>> VERB
    250 2.0.0 Verbose mode
    >>> STARTTLS
    220 2.0.0 Ready to start TLS
    >>> EHLO localhost.localdomain
    250-localhost.localdomain Hello localhost [127.0.0.1], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-EXPN
    250-VERB
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH DIGEST-MD5 CRAM-MD5
    250-DELIVERBY
    250 HELP
    >>> VERB
    250 2.0.0 Verbose mode
    >>> MAIL From: SIZE=32 [email protected]
    250 2.1.0 … Sender ok
    >>> RCPT To:
    >>> DATA
    250 2.1.5 … Recipient ok
    354 Enter mail, end with “.” on a line by itself
    >>> .

    6:32 am August 24, 2020 Reply
    • I’m got this too.

      9:10 am November 1, 2020 Reply
    • I have same issue

      11:48 pm January 21, 2021 Reply
    • aarushi

      i got this too, how to resolve

      8:30 am July 9, 2021 Reply
    • Dev

      got this issue too – email doesnt send. No error or output explaining why? Seems to hang?

      3:33 am August 16, 2021 Reply
      • Check your “mailq”. It’s probably stuck in the queue pending. You might see something like this

        r…@100pumpkins:~$ mailq
        MSP Queue status…
        /var/spool/mqueue-client is empty
        Total requests: 0
        MTA Queue status…
        /var/spool/mqueue (11 requests)
        —–Q-ID—– –Size– —–Q-Time—– ————Sender/Recipient———–
        22KHToXi011696* 18 Sun Mar 20 10:29
        (Deferred: Connection timed out with alt4.gmail-smtp-in.l.goo)

        5:54 pm March 20, 2022 Reply
  • Nags

    Thanks, it worked for me. I have question, i need to configure to use Sendmail only as Sending SMTP server. I have apps hosted in EC2 instance and from those apps i want send emails to specific email-groups basaed on events, for example JIRA or from Confluence. How can i do that ?, do you have any other article which can help me in this ?

    10:41 am August 31, 2020 Reply
  • mehaview

    Hi all
    i had this error : 530 Authentication required
    how to solve it ?

    11:38 am October 24, 2020 Reply
  • Linus

    Do you know what the problem might be when an additional name is added to the sender?

    liwa@BRITNEYSPEARS:~$ sendmail -v

    >>> MAIL From: SIZE=49 [email protected]
    250 2.1.0 … Sender ok

    It just adds a FQDN, and then the domain on top of that. Might it be a corrupt SPF1 record or something?

    2:52 pm November 9, 2020 Reply
  • sbaumg2s

    How does sendmail know with which credentials it has to log in into let´s says an gmail account? sending mail via sendmail from command line works, but i don´t understand why. Why can i login into the account without me having told it what the credentials are?

    9:42 am July 13, 2021 Reply
  • This just worked, so so thankfull!!!!

    11:12 am August 6, 2021 Reply
  • Send mail locally is well working but i want to integrate in django submitted form any relation ?

    11:33 am August 17, 2021 Reply
  • Rohit Bhatt

    Same issue

    6:45 pm October 23, 2021 Reply
  • Still works in Jan 2022¬ 😀

    11:41 am January 10, 2022 Reply
  • D.L Chavda

    Hello
    I got the below error after installing and now email is not working for me could you please have any solution for it thanks.
    stat=Deferred: Connection refused by _dc-mx.2c58b923df4b.iceel.net.client_loop: send disconnect: Connection reset

    3:10 am March 19, 2023 Reply
  • Claudio

    HI!
    I need Sendmail to get server status updates, so I need the server to only send to my personal email address. Is it possible to do this by following this guide?

    Thank you

    2:58 pm May 9, 2023 Reply
Write a comment