If mail relaying is not configured properly then your mail server could relay spam!
TEST HOW YOUR SENDMAIL IS CURRENTLY RESOLVING/SENDING...
sendmail -bv -oL10 email@address.com // -bv (verify mode without collecting/receiving msg)
-oL10 (log level 10 reports the mailer & host to which it resolves)
user@adomain.com... deliverable: mailer esmtp, host domain.com., user user@adomain.com
sendmail -v username@domain.com // -v (verbose report alias expansion)
you must then type in a message (it's waiting for you)
then finish the message with a . and a CR LF .
// or you can use CTRL-D to end a message
// alternatively you can nano mail.txt and write up your email nano message.txt
date: todays-date to: user@domain.com subject: subject from: your-name@domain.com
Body of message goes here
control + x to save and close
/usr/sbin/sendmail -t < message.txt
cat - file.log << EOF | sendmail -t to:recipient@somewhere.com from:you@yourdomain.com subject:Testing 123
EOF
i don't think this works...
/usr/sbin/sendmail different@email.com < mail.txt
rfc822 notifies us that our date time should actually be like:
date-time = [ day "," ] date time ; dd mm yy ; hh:mm:ss zzz
day = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun" date = 1*2DIGIT month 2DIGIT ; day month year ; e.g. 20 Jun 82
month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
hour = ; 00:00:00 - 23:59:59
confused yet? try examples...
Fri, 31 Oct 1999 15:14:31 +0200
31-10-2010 13:59 GMT
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Then for a "real" test email...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
mail -s "Test subject for email" user@domain.com
-c = Copy < means you could read the email in from a file?
We could send a binary file "filename.jpeg" using this command:
mail -s "picture" user@domain.com < filename.jpeg
but chances are high that the image will be unusable the time it arrives at the recipient.
uuencode surfing.jpeg surfing.jpeg | mail user@example.com
Mimencode is intended to be a replacement for uuencode for mail and news use as uuencode doesn't work very well in a number of circumstances and ways: uuencode uses characters that don't translate well across all mail gateways (particularly ASCII <-> EBCDIC gateways).
The mimencode program simply converts a byte stream into (or out of) one of the standard mail encoding formats defined by MIME, the proposed standard for internet multimedia mail formats.
POSTFIX postconf -n
postqueue -p # the list of messages according to postfix/sendmail postsuper -d QUEUEID # delete a message from the QUEUE postsuper -d ALL # delete all messages
/var/spool/mqueue //the mail queue
/var/log/mail or /var/log/syslog will show you the results of an attempted emailing
/etc/mail/aliases
contains who's the postmaster...
/etc/mail/local-host-names lists all of the domains Sendmail will accept email for
/etc/mail/access
Connect:localhost.localdomain RELAY Connect:localhost RELAY Connect:127.0.0.1 RELAY
Controls who can relay email through your server - THIS IS THE FILE YOU NEED TO ENSURE does not allow random hackers to send spam...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- THEORY incoming mail is processed by sendmail and put into the mailbox file of the user's account
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
outgoing mail is either routed internally (e.g. one user to another on same linux server) or externally: gets DNS to get MX record
SETUP sendmail to relay through exchange server (e.g. forward email to a smart host)
/etc/mail/sendmail.mc
define(SMART_HOST',
majestix')dnl
m4 sendmail.mc > /etc/sendmail.cf
ODDLY, IN UBUNTU 8.04 THIS GIVES YOU A FUNNY ERROR
ERROR: FEATURE() should be before MAILER()
MAILER(local') must appear after FEATURE(
always_add_domain') ERROR: FEATURE() should be before MAILER()
MAILER(local') must appear after FEATURE(
allmasquerade')*** ERROR: FEATURE() should be before MAILER()
Basically the default sendmail.mc file has the options in the wrong order...
The fix is moving the following lines to the end of the file (e.g. after the FEATURE commands...)
dnl # Default Mailer setup
define(SMART_HOST',
andersmail')dnl
MAILER_DEFINITIONS
MAILER(local')dnl
MAILER(
smtp')dnl
(Note the funny ` versus ' )
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- An alternative route is a bit complicated...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Add to the end the line: Feature ('mailertable', 'hash -o /etc/mail/mailertable.db') dnl
FEATURE(mailertable',
hash -o /etc/mail/mailertable.db')dnl
In the file mailertable I created the following line mydomainname.com ESMTP:[192.168.100.222]
makemap hash /etc/mail/mailertable.db < /etc/mail/mailertable
http://www.sendmail.org/m4/readme.html ?
http://esmtp.sourceforge.net/manual.html esmtp is a user configurable relay-only Mail Transfer Agent (MTA) with a sendmail compatible syntax
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- host servername //this will return the ip address of a lookup
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
The sendmail program expects DNS to be configured correctly on the DNS server. This means /etc/resolv.conf and /etc/hosts should ensure that you can see the right ip addresses for the right servers
Linux does not function properly if the 127.0.0.1 entry in /etc/hosts doesn't also include localhost and localhost.localdomain
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- If your linux server is not going to be sending email directly (e.g. it will merely pass email onto another server...)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/etc/mail/sendmail.mc
define(SMART_HOST',
mail.my-site.com')
/etc/mail/sendmail.conf
LOG_CMDS="Yes";
then you must run sendmailconfig or .../sendmail/update_config
you can write an email using the commands
or
mailx https://engineering.purdue.edu/ECN/Support/KB/Docs/MailXTutorial
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TO INSTALL SENDMAIL (sendmail.org) apt-get install sendmail //or download/compile the binary... ./Build
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Configuration is done via .mc files which are processed by "m4" into .cf files...
e.g. /etc/mail/sendmail.mc MASQUERADE_AS('servername.com')dnl
You need to insure that DNS is running and that your '/etc/mail/sendmail.cf' is configured appropriately for routing. This can be as simple as specifying the 'DS' macro to look something like:
DSexchange.xyz.com
comments in '/etc/mail/sendmail.cf' will guide you.
TROUBLESHOOTING
Connecting to [127.0.0.1] via relay... Deferred: Connection refused by [127.0.0.1]
This is an easy error - apparently sendmail hasn't been started
netstat -an
(look for anything listening on port 25)
or netstat -an | grep :25
ANOTHER WAY OF VERIFYING:
telnet localhost 25
Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused telnet: Unable to connect to remote host: Connection refused
ANOTHER WAY OF VERIFYING:
/etc/init.d/sendmail
/etc/init.d/sendmail status
/etc/init.d/sendail restart
Now suddenly your emails will start going out (assuming that /etc/mail is all configured correctly)
Don't forget your firewall (and iptables)!