Skip to content

Instantly share code, notes, and snippets.

@adamstac
Last active January 5, 2024 00:01
Show Gist options
  • Star 89 You must be signed in to star a gist
  • Fork 39 You must be signed in to fork a gist
  • Save adamstac/7462202 to your computer and use it in GitHub Desktop.
Save adamstac/7462202 to your computer and use it in GitHub Desktop.
Install and configure Sendmail on Ubuntu

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

  1. If sendmail isn't installed, install it: sudo apt-get install sendmail
  2. Configure /etc/hosts file: nano /etc/hosts
  3. Make sure the line looks like this: 127.0.0.1 localhost yourhostname
  4. Run Sendmail's config and answer 'Y' to everything: sudo sendmailconfig
  5. Restart apache sudo service apache2 restart
@youssman
Copy link

Not working on ubuntu 16.04. It is hanging while trying to generate ssl certificates.

More details here

@crmpicco
Copy link

Really useful, thanks.

@sensonicm
Copy link

@SavaNETgit Hi all!
In the example above there was an address "reciever@me.com", you need to specify an address with a specific zone, e.g. "sensonicm@gmail.com" The example did not work because the service could not determine the address.
@youssman
Everything works, look in the internet for information - you need to create a certificate before installation. It hangs during installation on the generation of the certificate. Spend the time, look, I have no time. If you do not find write, I'll find)

@elewinso
Copy link

getting this error, help will be greatly appreciated.

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package sendmail is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sendmail' has no installation candidate

@gianpaj
Copy link

gianpaj commented Mar 21, 2018

@elewinso, try to run:

sudo apt-get update

@TheRatG
Copy link

TheRatG commented Apr 10, 2018

I have to run

cd /etc/mail/tls
sudo openssl dsaparam -out sendmail-common.prm 2048
sudo chown root:smmsp sendmail-common.prm
sudo chmod 0640 sendmail-common.prm
sudo dpkg --configure -a

@eugenelee0420
Copy link

The installation will hang on Ubuntu 16.04, the solution is to run these commands:

sudo openssl dsaparam -out sendmail-common.prm 2048
sudo chown root:smmsp sendmail-common.prm
sudo chmod 0640 sendmail-common.prm
sudo dpkg --configure -a

Reference: https://askubuntu.com/questions/937666/ubuntu-16-04-command-line-sendmail-installation-hanged

@Keyzo-Gakiya
Copy link

Worked fine for me (Ubuntu 18.04), Thanks!

@nilliu
Copy link

nilliu commented Sep 17, 2018

really helpful.
I did only from step 1 to 4,
then it's works like a charm!

my use case is sending internal system(ubuntu 18.04) email notification to users in corporate colleague,
and no need of posfix, just need follow step 1 to 4, fast and neat!

thank you.

@yfarooq
Copy link

yfarooq commented Oct 3, 2018

Hi @yfarooq !
Congratulations on the coming New Year!
We would have made the world better if we told how we solved our problems)))
Or not yet solved?
The problem in determining the e-mail address in the listing about this is written, the address should be of the form: some@some.zone(add [.zone] to normal resolve mail address).

I still can't get this to work.

Error: /etc/mail/submit.cf: line 6: invalid argument to V line: "ERSIONID(Id: startt"
/etc/mail/submit.cf: line 7: invalid argument to V line: "ERSIONID(Id: autoco"

I tired to comment both line 6 and 7 with # and still can't receive email

@inneroot
Copy link

inneroot commented Dec 4, 2018

'yourhostname' should be long,
that mean, it should have dot com or similar, or you will get error in log:

unable to qualify my own domain name (hostname) - using short name.

@bitridge
Copy link

bitridge commented Jul 9, 2019

For this I think you'll also have to allow gmail on less secure app https://support.google.com/accounts/answer/6010255?hl=en

@NSBSD-InfoTech
Copy link

Its working for me, the problem is the email address showing up on my email is it@localhost, how can I make it to show the hostname of the server and not localhost?

@sarraHa
Copy link

sarraHa commented Dec 3, 2019

Worked fine for me (Ubuntu 18.04), Thanks!

I used this tutorial for ubuntu 18.04
https://www.youtube.com/watch?v=_nwJ63UhJTM

@jet2018
Copy link

jet2018 commented Feb 24, 2020

after doing your steps, i get this
[Mon Feb 24 09:50:24.782752 2020] [mpm_prefork:notice] [pid 11060] AH00169: caught SIGTERM, shutting down
[Mon Feb 24 09:52:08.852440 2020] [mpm_prefork:notice] [pid 1128] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Mon Feb 24 09:52:09.024401 2020] [core:notice] [pid 1128] AH00094: Command line: '/usr/sbin/apache2'

what do i do?

@iotstudent
Copy link

pls how do i locate the sendmail.ini file in ubuntu 18

@bhaijiyunus
Copy link

bhaijiyunus commented Apr 16, 2020

HI,
I run the below commands on my Ubuntu 18.04 to configure the sendemail/sendmail, I am getting email success message but never received an email. Help will appreciate. Thanks.
Apr 16 15:45:01 ubuntu sendemail[29360]: Email was sent successfully!
systemctl stop postfix
sudo apt remove postfix
sudo apt purge postfix
sudo apt-get install mailutils
sudo apt-get install sendmail sendemai

@charity1475
Copy link

How to make sendmail work in a LAN? or between two computers connected via eht0

@bitridge
Copy link

How to make sendmail work in a LAN? or between two computers connected via eht0

Good question, I'm following

@Dissorder
Copy link

Hi @bhaijiyunus I'm getting the same issue. Were you able to solve it?

@thesimonshields
Copy link

Not working for me either

wondering if I could get the code and compile it

i get errors around missing packages javascript-common & sometimes java-common

sudo apt -f install sendmail
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-5.4.0-74-generic linux-headers-5.4.0-77-generic linux-hwe-5.4-headers-5.4.0-56 linux-hwe-5.4-headers-5.4.0-58
linux-hwe-5.4-headers-5.4.0-74 linux-hwe-5.4-headers-5.4.0-77 linux-image-5.4.0-74-generic linux-image-5.4.0-77-generic
linux-modules-5.4.0-74-generic linux-modules-5.4.0-77-generic linux-modules-extra-5.4.0-74-generic linux-modules-extra-5.4.0-77-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
liblockfile-bin liblockfile1 lockfile-progs procmail sendmail-base sendmail-bin sendmail-cf sensible-mda
Suggested packages:
sendmail-doc rmail logcheck resolvconf sasl2-bin
The following NEW packages will be installed:
liblockfile-bin liblockfile1 lockfile-progs procmail sendmail sendmail-base sendmail-bin sendmail-cf sensible-mda
0 to upgrade, 9 to newly install, 0 to remove and 292 not to upgrade.
Need to get 0 B/899 kB of archives.
After this operation, 4,449 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package liblockfile-bin.
dpkg: warning: files list file for package 'javascript-common' missing; assuming package has no files currently installed
dpkg: unrecoverable fatal error, aborting:
files list file for package 'libv4l-0:i386' contains empty filename
E: Sub-process /usr/bin/dpkg returned an error code (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment