sendmail: how to configure sendmail on ubuntu? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
When I searched for configuring sendmail on ubuntu I din’t get any clear answer, each of them assume I know what they are talking about, I just want basic configuration to enable email sending, basically I will use it with google app engine to enable mail sending from dev server. I already did this:
sudo apt-get install sendmail
None of these answers worked for me. I found this online article that works for me: daveperrett.com/articles/2013/03/19/…
@PJBrunetWhile I do think sendmail is obsolete (there are much better alternatives!), my comment FIVE YEARS ago was simply about the fact that we do not migrate questions that old to another SE site.
3 Answers 3
When you typed in sudo sendmailconfig , you should have been prompted to configure sendmail.
For reference, the files that are updated during configuration are located at the following (in case you want to update them manually):
/etc/mail/sendmail.conf /etc/cron.d/sendmail /etc/mail/sendmail.mc
You can test sendmail to see if it is properly configured and setup by typing the following into the command line:
$ echo "My test email being sent from sendmail" | /usr/sbin/sendmail myemail@domain.example
The following will allow you to add smtp relay to sendmail:
#Change to your mail config directory: cd /etc/mail #Make a auth subdirectory mkdir auth chmod 700 auth #Create a file with your auth information to the smtp server cd auth touch client-info #In the file, put the following, matching up to your smtp server: AuthInfo:your.isp.net "U:root" "I:user" "P:password" #Generate the Authentication database, make both files readable only by root makemap hash client-info < client-info chmod 600 client-info cd ..
Add the following lines to sendmail.mc, but before the MAILERDEFINITIONS . Make sure you update your smtp server.
define(`SMART_HOST',`your.isp.net')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash -o /etc/mail/auth/client-info.db')dnl
Invoke creation sendmail.cf (alternatively run make -C /etc/mail ):
m4 sendmail.mc > sendmail.cf
Restart the sendmail daemon:
Linux Sendmail Configuration:
This tutorial covers the configuration of a Linux email server using the Sendmail MTA (Mail Transfer Agent). Virtual hosting is also covered to allow one to perform email services for multiple domains. The following configuration is for recieving inbound email.
Related YoLinux Tutorials:
Sendmail is the default MTA on the RedHat Linux distribution. Do NOT use linuxconf to configure sendmail as it has NOT been updated to work with current versions of sendmail. (The tool linuxconf is no longer included with current versions of Red Hat Linux 7.3+)
RPM packages required: sendmail, sendmail-cf and m4
Ubuntu/Debian install: sudo apt-get sendmail sendmail-base sendmail-bin sendmail-cf mailutils
Sendmail receives mail for local system user login accounts. Mail is held in a single file: /var/mail/userID
Steps to run mail server using sendmail:
- Required for inbound mail: The mail server must be identified by the DNS as the mail server in order to receive mail. See the YoLinux web tutorial on configuring DNS.
- /etc/mail/local-host-names (Required) (Red Hat 7.1 - Fedora Core 3)
/etc/sendmail.cw (Red Hat 6.x) This file contains all of the alternate host names of the server. (i.e. domain-name.com) Sendmail will not accept mail for a domain unless it is permitted to do so by the contents of this file.
Sample:
megawebhost.com
yolinux.com
yo-linux.com
webmaster: john, dave postmaster: kim, garret larry.anderson: larry moe.anderson: moe curly.anderson: curly
webmaster@domain-1.com dave webmaster@domain-2.com john john@domain-2.com john @domain-2.com error:nouser User unknown @domain3.com mathew
localhost.localdomain RELAY localhost RELAY 127.0.0.1 RELAY
[root prompt]# makemap hash /etc/mail/access.db < /etc/mail/access
The access file can be used to thwart spammers. List IP addresses or email address to deny in the file: /etc/access
After adding entries to the access file, generate the database file with the command above.
XXX.XXX.XXX.XXX REJECT YYY.YYY.YYY.YYY ERROR:"550 We don't accept mail from spammers" spammer@isp.com REJECT " Spam not accepted" ZZZ.ZZZ.ZZZ.ZZZ OK - Override rules and allow ZZZ.ZZZ OK - Allow from ZZZ.ZZZ.*.* network
The default configuration is fairly secure and usable. For Red Hat 6 and earlier systems, you are ready to mail. For Red Hat 7 systems, there is one more step. See changes below required to receive mail.
Note: A user defined in the aliases file is valid for all domains hosted by the system, unless you have configured virtual hosting.
For alternate configurations change the file: sendmail.cf
The config file sendmail.cf has become so complex that most people use the m4 macro package to generate this file from a sendmail.mc file. Pre-configured ".mc" files can be found in the directory:
- /etc/mail/ (Red Hat 9.0 - Fedora Core 3)
- /usr/lib/sendmail-cf/cf/ (Red Hat 7.1)
- /usr/share/sendmail-cf/cf/ (Red Hat 6.x)
Default Red Hat sendmail.cf configurations:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
cd /usr/share/sendmail-cf/cf/
m4 redhat.mc > /etc/sendmail.cf
cd /usr/lib/sendmail-cf/cf/
m4 ../m4/cf.m4 redhat.mc > /etc/sendmail.cf
(Red Hat 7.1-7.3, 8, 9, RHEL4, Fedora Core X)
If you just installed or upgraded to red Hat 7.1 or later and noticed that your mail server does not recieve email, it is because of the Red Hat default sendmail configuration. The default configuration for Red Hat (7.1 or later) sendmail does not allow for the receiving of mail except from yourself (localhost).
Configure to receive email:
- Backup the files /etc/mail/sendmail.mc and /etc/sendmail.cf
- Edit the file /etc/mail/sendmail.mc and change/comment the line:
From: DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
To: dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
FEATURE(`dnsbl', `proxies.blackholes.easynet.nl', `"550 5.7.1 ACCESS DENIED to OPEN PROXY SERVER "$&" by easynet.nl DNSBL (http://proxies.blackholes.easynet.nl/errors.html)"', `')
FEATURE(`dnsbl', `bl.spamcop.net', `"450 Mail from " $`'& " refused - see http://spamcop.net/bl.shtml"')
FEATURE(`dnsbl',`sbl.spamhaus.org',`Rejected - see http://spamhaus.org/')
- Turn off relaying (Relaying is denied by default Red Hat configuration) Do NOT use the following directive: FEATURE(`promiscuous_relay')
- Check sender information:
- Accept mail from your own domain: FEATURE(`relay_entire_domain')
- Accept relay from your mail servers listed in MX record to destination in same domain: FEATURE(`relay_based_on_MX')
- Comment out: dnl # FEATURE(`accept_unresolvable_domains')dnl
(RHEL4)
- define(`confMAX_DAEMON_CHILDREN', 12)
- define(`confCONNECTION_RATE_THROTTLE', 3)
MASQUERADE_AS(your-domain.com) MASQUERADE_DOMAIN(your-domain.com) MASQUERADE_DOMAIN(virt-domain-1.com) - Add list of other domains supported MASQUERADE_DOMAIN(virt-domain-2.com) by your server here if required . .. FEATURE(masquerade_entire_domain) FEATURE(masquerade_envelope)
Cwlocalhost.localdomain
[Potential Pitfall] : To comment out a line use:
[Potential Pitfall] : Some distributions have a default configuration which causes failure. The /etc/hosts.deny entry ALL:ALL will cause failure to receive mail.
- Look for errors in /var/log/maillog
- Red Hat/Fedora Core systems come with the user smmsp which is required for operation. Do not remove!
File: /etc/passwd
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
Directive Description divert(-1) m4 macro directive. File output not diverted OSTYPE(`linux') Required before definitions. Definitions tied to OSTYPE. define('VARIABLE','VALUE') Change a setting in sendmail.
See listundefine(`UUCP_RELAY') Remove UUCP email processing capability undefine(`BITNET_RELAY') Remove BITNET addressed email processing FEATURE() See list of features FEATURE(redirect) Reject redirected email addressed to user@domain.com.REDIRECT
Message returned to announce that one should send email to address defined by alias.FEATURE(always_add_domain) Append fully qualified domain name of host to user name. FEATURE(use_cw_file) File /etc/sendmail.cw defines alternate names of host. MAILER() See list of Mailers MAILER(procmail) Defines procmail as the local mail program on server. MAILER(smtp) Remote mail program. dnl: m4 directive to delete whitespace in input
Directive Description define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl Disable "vrfy" so that spammers cannot "verify" typical email addresses such as info, admin, staff, etc. define(`ALIAS_FILE', `/etc/aliases')dnl This states the obvious. Email address aliases are defined in the file: /etc/aliases FEATURE(`smrsh',`/usr/sbin/smrsh')dnl Execute Sendmail using the Sendmail restricted shell Sendmail documentation:
DNS and Sendmail Presentation at LUGFest 2000 - (Star Office 5.2 "sdd" file) - More configuration insight and information.
- mailq : Print a summary of the mail messages queued for future delivery.
Mail is queued in directory: /var/spool/mqueue/ - mailstats : Display current mail statistics.
Mail statistics stored in file: /var/log/sendmail.st/ - praliases : Display current mail aliases
Check if an open relay: (you do not want to be an open relay)
- Interactive shell session:
$ /usr/sbin/sendmail user@domain.com enter body of message here ctrl-d
date: Thu Nov 13 10:37:14 2008 to: user@domain.com subject: subject from: your-name@your-domain.com Body of message goes here
#!/usr/bin/perl use Time::localtime; open (OUT,"|/usr/sbin/sendmail -t"); print OUT "From: your-email\@domain.com\n"; ## escape the @ or put in single quotes print(OUT "Date: ".ctime()."\n"); print(OUT "To: $email\n"); print(OUT "Subject: $subject\n"); print(OUT "\n"); print(OUT "$body
(Ubuntu note: the sendmail command /usr/sbin/sendmail (not the email server) also comes with the package postfix.)
The most comprehensive book on Sendmail.