User Tools

Site Tools


aix:sendmail

Sendmail on AIX

submit.cf

A workaround to prevent using submit file, is to crate a symbolic link between /etc/mail/sendmail.cf and /etc/mail/submit.cf (check section sendmail.cf)

https://www.ibm.com/support/pages/how-run-two-sendmails-one-mtamail-transfer-agent-and-another-msamail-submission-agent

How to run two sendmails, one for MTA(Mail Transfer Agent) and another for MSA(Mail Submission Agent).

sendmail.cf

For more secure sendmail in AIX 7.2 TL4

https://www.ibm.com/support/knowledgecenter/ssw_aix_72/s_commands/sendmail.dita

https://www.ibm.com/support/pages/node/6378270?myns=aix&mynp=OCSG11S&mync=E&cm_sp=aix-_-OCSG11S-_-E

Sendmail was updated in newer AIX versions and it works differently 
now, it requires sendmail running to send and receive emails

"AIX® version AIX 7 with 7200-03 and earlier used sendmail.cf 
configuration file for the sendmail command. Starting with AIX 
version AIX 7 with 7200-04 two configuration files sendmail.cf 
and submit.cf are installed. The sendmail command uses the 
submit.cf configuration file by default. The sendmail.cf file 
exists for compatibility with earlier versions of the sendmail 
command. The following 
information is valid for both sendmail.cf and submit.cf 
configuration files."
You can read more about this here: https://www.ibm.com/docs/en/aix/7.2?topic=files-sendmailcf-submitcf-file

Sendmail configuration

To setup sendmail, update the file sendmail.cf, and check that /etc/senmail.cf is a symbolic link. The file used by sendmail is /etc/mail/sendmail.cf

[root@nimsrv]/etc# ls -l /etc/sendmail.cf /etc/mail/sendmail.cf
56 -rw-r--r-- 1 root system 53277 Aug 16 12:07 /etc/mail/sendmail.cf
 0 lrwxrwxrwx 1 root system    21 Jun  1  2012 /etc/sendmail.cf -> /etc/mail/sendmail.cf

Be care full each AIX update will reset the sendmail.cf file to default values.

Sendmail.cf configuration:

change the #Dj$w.Foo.COM by : Djsmtpserver.local.com
change DS with your mail domain: DSmymail.com
...  
##################
#   local info   #
##################

# my LDAP cluster
# need to set this before any LDAP lookups are done (including classes)
#D{sendmailMTACluster}$m

Cwlocalhost
# file containing names of hosts for which we receive email
# Fw/etc/mail/local-host-names

# my official domain name
# ... define this only if sendmail cannot automatically determine your domain
#Dj$w.Foo.COM

# host/domain names ending with a token in class P are canonical
CP.

# UUCP relay host
#DYrelayhostname
#CPUUCP

# "Smart" relay host (may be null)
DS
....

Sendmail service

http://www.deer-run.com/~hal/sysadmin/sendmail.html

If you wants to start sendmail service, use the following command. It can be activate at restart, by uncommented the sendmail line into /etc/rc.tcpip. Sendmail service is not needed to send email on AIX, it can just resend mails in case of trouble.

# startsrc -s sendmail -a "-bd -q30m"

The reality, however, is that the Sendmail daemon on a machine is only responsible for two things:

  • Listening on port 25/tcp for incoming messages from outside of the machine
  • Flushing the local queue of unsent messages on a periodic basis

aliases

alias configuration for sendmail in MSP mode (applicable only beyond AIX version 7200-04-02).

To configure the aliasing in sendmail, which runs in mail submission program mode (MSP). Mail aliasing in sendmail, which is being run in mail submission program mode.

Steps

To configure the alias while sending a mail with sendmail in Mail Submission Program mode. Mailer flag in /etc/mail/submit.cf file should be modified to add alias flag “A” as part of F attribute.

Sample change to mailer flag in “/etc/mail/submit.cf” :

Mlocal, F=lmDFMuXkw5
to
Mlocal, F=lmDFMAuXkw5  

Alias flag “A” is added to mailer as part of F attribute as shown above.

When adding a new alias into /etc/mail/aliases

Ex:

TEST: user@machine
testalias: TEST

The /etc/mail/aliases file is a raw data file. The sendmail command uses a database version of this file. You must build a new alias database by running the sendmail -bi command or the newaliases command before any changes made to the /etc/mail/aliases file become effective.

logging

You can simply add an entry into /etc/syslog.conf, create the logfile and restart syslogd daemon

mail.debug   /var/log/syslog/mail.log rotate size 500k files 4 compress

Sendmail howto

On AIX sendmail daemon is not required to send an email to a Exchange server. Sendmail daemon is used if the AIX server act as email server.

Sendmail config file is located in /etc/mail/sendmail.cf, /etc/sendmail.cf is just a symbolic link. It contain the sendmail server destination and if needed a default domain

[root@aix01] /var/spool/mail> grep DS /etc/sendmail.cf
# COMPONENT_NAME: CMDSEND sendmail.cf
DSsmtp-server.exchange.lu
# Return-Receipt-To: header implies DSN request
# DHParameters (only required if DSA/DH is used)
# Smart-Host relay defined by "DS" macro.
[root@aix01] /var/spool/mail> grep Dj /etc/sendmail.cf
#Dj$w.Foo.COM

A email which is send to the server will be temporary stored to /var/spool/mqueue, and has a data file and a control file. If the mail is not send it stays in this folder. You can check pending mail, if the date is not known, check in the folder le files date using the commands:

[root@aix01] /var/spool/mqueue> mailq
                /var/spool/mqueue (2 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
s0968Jhr32571522      107 Thu Jan  9 07:08 apipnr
                 (Deferred: Connection timed out with smtp-server.exchange.lu.)
                                         my.email@mydomain.lu
q68100WD15597764  (no control file)
                Total requests: 2
[root@aix01] /var/spool/mqueue> ls -l
total 16
   4 drwxrwx---    2 root     system         4096 Sep  1 10:05 .
   4 drwxrwxr-x   13 bin      bin            4096 Nov  4 2010  ..
   0 -rw-------    1 root     system            0 Jul  8 2012  dfq68100WD15597764
   4 -rw-------    1 root     system          107 Jan  9 2014  dfs0968Jhr32571522
   0 -rw-------    1 root     system            0 Jul  8 2012  qfq68100WD15597764
   4 -rw-------    1 root     system          804 Jan  9 2014  qfs0968Jhr32571522
   4 -rw-------    1 root     system          609 Jun 28 2015  qft5SFd05T7864368
   4 -rw-------    1 root     system          609 Feb 11 2015  qfv1B4s1Dr7864368
   4 -rw-------    1 root     system            1 Jun 28 2015  dft5SFd05T7864368
   4 -rw-------    1 root     system            1 Feb 11 2015  dfv1B4s1Dr7864368

Here we can see other mail IDs, which are lost mail, better is to delete then. It can also come from a previous installation (clone using mksysb)!

You can try to resend queued mail, but first check the date, if too old better is to delete, but check with the destination. Try the following command:

[root@aix01] /var/spool/mqueue> sendmail -q

Test SMTP communication

Test the communication with your mail server:

An easy way to test by using

stoprsc -s sendmail
/usr/lib/sendmail -v -q30s -X /tmp/sendmail.debug

telnet mail.test.com 25

Trying...
Connected to mail.test.com.
Escape character is '^T'.
220 MAIL.test.com Microsoft ESMTP MAIL Service ready at Fri, 29 Apr 2011 17:17:48 +0200

ehlo test.com

250-mail.test.com Hello [10.10.10.5]
250-SIZE 104857600
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 XEXCH50

ehlo test1.com

250-MAIL.test.com Hello [10.10.10.5]
250-SIZE 104857600
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 XEXCH50

MAIL From:<labotest@test.com>

250 2.1.0 Sender OK

RCPT To:<test@yahoo.com>

250 2.1.5 Recipient OK

DATA

354 Start mail input; end with <CRLF>.<CRLF>

subject test labotest

.

250 2.6.0 <c94e6500-82ae-4c42-a9f5-6736f87344b1@MAIL.test.com> Queued mail for delivery

quit

221 2.0.0 Service closing transmission channel
Connection closed.

The complex way: to use sendmail and html formatting:

v_mailpart="$(uuidgen)/$(hostname)"
echo "To: my@email.com
Subject: subject
Content-Type: multipart/mixed; boundary=\"$v_mailpart\"
MIME-Version: 1.0

This is a multi-part message in MIME format.
--$v_mailpart
Content-Type: text/html
Content-Disposition: inline

<html><body>Message text itself.</body></html>

--$v_mailpart
Content-Transfer-Encoding: base64
Content-Type: application/octet-stream; name=file_name.ext
Content-Disposition: attachment; filename=file_name.ext

`base64 /path/to/file`
 --$v_mailpart--" | /usr/sbin/sendmail -t

change SMTP server port

Change into the file /etc/sendmail.cf, the SMP servername mailrelayserver.domain.com, and the port 2525

...
# “Smart” relay host (may be null)
DSmailrelayserver.domain.com
...
Msmtp,          P=[IPC], F=mDFMuX, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP/HdrFromSMTP, E=\r\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h 2525
Mesmtp,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP/HdrFromSMTP, E=\r\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h
Msmtp8,         P=[IPC], F=mDFMuX8, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP/HdrFromSMTP, E=\r\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h
Mdsmtp,         P=[IPC], F=mDFMuXa%, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP/HdrFromSMTP, E=\r\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h
Mrelay,         P=[IPC], F=mDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP/MasqRelay, E=\r\n, L=2040,
                T=DNS/RFC822/SMTP,
                A=TCP $h

Debug / trace

# startsrc –s iptrace –a "-b 2000000000 –p 25,53 /tmp/iptrace.log"

# echo "test" | mail –v "test email" email@test.com > /tmp/mail_test.log

# stopsrc -s iptrace

AIX script to log all mails

If you use mail_files script, it allows you to trace all mails. AIX scripts

aix/sendmail.txt · Last modified: 2022/12/19 23:50 by manu