Archive

Posts Tagged ‘sendmail’

sendmail DSN: Data format error

March 5th, 2015 Comments off

If you met error when sending mail using sendmail(or linux mail/mailx command), then you should check /var/log/maillog for details. For example:

Mar 5 02:39:10 testhost1 sendmail[15281]: t252dAZr015281: from=root, size=78, class=0, nrcpts=1, msgid=<201503050239.t252dAZr015281@testhost1.us.example.com>, relay=root@localhost
Mar 5 02:39:10 testhost1 sendmail[15282]: t252dA8Z015282: from=<root@testhost1.us.example.com>, size=393, class=0, nrcpts=1, msgid=<201503050239.t252dAZr015281@testhost1.us.example.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Mar 5 02:39:10 testhost1 sendmail[15281]: t252dAZr015281: to=user1@example.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30078, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t252dA8Z015282 Message accepted for delivery)
Mar 5 02:39:10 testhost1 sendmail[15284]: t252dA8Z015282: to=<user1@example.com>, ctladdr=<root@testhost1.us.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120393, relay=smtpserver1.example.com. [192.151.231.4], dsn=5.6.0, stat=Data format error
Mar 5 02:39:10 testhost1 sendmail[15284]: t252dA8Z015282: t252dA8Z015284: DSN: Data format error
Mar 5 02:39:10 testhost1 sendmail[15284]: t252dA8Z015284: to=<root@testhost1.us.example.com>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31660, dsn=2.0.0, stat=Sent

From here, you can see that after relaying, the mail finally failed with DSN code 5.6.0(Delivery Status Notification extension of SMTP). So you should check the code details:

5 Permanent or Fatal error. This can be caused by a non existent email address, DNS problem, or your email was blocked by the receiving server.
X.6.0 - Other or undefined media error

X.6.0 Other or undefined media error Not given Something about the content of a message caused it to be considered undeliverable and the problem cannot be well expressed with any of the other provided detail codes.

PS:

For more info abotu DSN code, you can check http://www.inmotionhosting.com/support/email/email-troubleshooting/smtp-and-esmtp-error-code-list or http://tools.ietf.org/rfc/rfc3463.txt or http://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xml for details.

Categories: IT Architecture, Linux, Systems Tags:

mail sendmail terminologies – MUA MSA MTA MDA

June 3rd, 2013 Comments off

A detailed flow of a message

MUA(outlook, mail, mutt) → MSA → MTA(sendmail) → … → MTA → MDA(procmail) →→ MRA(fetchmail) →→ MUA,

with the arrow styles changing to distinguish between push
 steps (→) and pull
 steps (→→).

Programs such as fetchmail which retrieve email from a server but do not provide a human interface for viewing or other client tasks are referred to as MRAs – they provide retrieval
 but no other client functions. Traditionally and in internet standards (such as the recent RFC 5598) these are referred to as a type of MUA, because they are client-side and hence outside the scope of internet standards, and indeed many MUAs perform MRA functions.

However, traditional Unix email readers such as elm, Pine, or mutt would often not include MRA functions (or only optionally), reading email that had already been delivered to a mailbox file (formally, delivered
 by an MDA).

Here's more info about mail/sendmail:

cat space_mail.txt | /bin/mailx -s "test subject" -c cc1@example.com,cc2@example.com to1@oracle.com to2@example.com #or mailx -s "subject" recipient@example.com<space_mail.txt

smtp
Normally, mailx invokes sendmail(8) directly to transfer messages. If the smtp variable is set, a SMTP connection to the server specified by the value of this variable is used instead. If the SMTP server does not use the standard port, a value of server:port can be given, with port as a name or as a number.

And in /etc/mail/sendmail.cf:
# Relay all non-local mail to the "Smart" relay host (DS) via smtp:
# This macro is optional. If you wish to send all non-local mail
# to a smart relay via SMTP just set macro S (DS) to the name of the
# smart relay. If this macro is not set, then all mail addresses to
# a non-local user will be send to the relay. #
.
.
.
# "Smart" relay host (may be null)
DShostname.domain
To look at a specific message, use the type command, which may be abbreviated to simply t . For example, if you had the following messages:

O 1 drfoo@myhost.example Wed Sep 1 19:52 18/631 "Fees"
O 2 sam@friends.example Thu Sep 2 00:08 30/895
you could examine the first message by giving the command:
type 1
which might cause to respond with, for example:
Message 1:
From drfoo@myhost.example Wed Sep 1 19:52:25 2004
Subject: Fees
Status: R

Tuition fees are due next Wednesday. Don't forget!
Many mailx commands that operate on messages take a message number as an argument like the type command. For these commands, there is a notion of a current message. When you enter the mailx program, the current message is initially the first (or the first recent) one. Thus, you can often omit the message number and use, for example,
t

to type the current message. As a further shorthand, you can type a message by simply giving its message number. Hence,
1
would type the first message.
Frequently, it is useful to read the messages in your mailbox in order, one after another. You can read the next message in mailx by simply typing a newline. As a special case, you can type a newline as your first command to mailx to type the first message.

list

Prints the names of all available commands.

z
Mailx presents message headers in windowfuls as described under the headers command. The z command scrolls to the next window of messages. If an argument is given, it specifies the window to use. A number prefixed by '+' or '-' indicates that the window is calculated in relation to the current position. A number without a prefix specifies an absolute window number, and a '$' lets mailx scroll to the last window of messages.

env MAILRC=/dev/null from=scriptreply@domain smtp=<smtp server address> \
smtp-auth-user=<test@example.com> smtp-auth-password=<enter password> \
smtp-auth=login mailx -n -s "test" \
recipient@example.com <test/test.txt

1.telnet to send mail from command line
telnet xxx.xxx.xxx.xxx 25 #xxx.xxx.xxx.xxx stands for your mail server ip,same of the rest of the article
ehlo localhost #or helo doxer.org, to tell the mail server the domain you belong to
AUTH LOGIN #here we assume that account of your mail is service@yourdomain.tld,password iloveyou
c2VydmljZUB5b3VyZG9tYWluLnRsZA== #After the server has responded,type in the encoded username by base64 arithmetic.Method:echo -n 'service@yourdomain.tld'|base64
aWxvdmV5b3U= #type in the encoded password by base64 arithmetic.Method:echo -n 'iloveyou'|base64
mail from: username #if username here has space,using quotation marks to enclose it,like "user name"
rcpt to: customer@gmail.com #receiver
data
Subjet: My first mail on Postfix
Hi,
Are you there?
regards,
Admin
.
quit

OK!Now the customer of yours is expected to get your mail.(If not,please check your mail server's configurations,such as whether your mail server has a reverse DNS,and your mail server cannot be a open relay MTA,for many MTA refuse to receive letter from a open relay MTA.)
2.telnet to receive & read mail from command line
telnet xxx.xxx.xxx.xxx 110
USER service@yourdomain.tld #your account name,note that USER should be capitalized
PASS iloveyou #your password
list #to list the table of your unread messages
retr 2 #to read the content of the second unread message of the list
quit

3.mail to send mail from command line:
mail mail@yourdomain.tld #receiver
#after the response,type in the Subject of your mail
#Enter,then type in the content of your mail
#If you finish the content,press Ctrl+D to end the procedure(or using a dot . to end it).Then it prompts Cc(carbon copy).If the mail has a Cc,just type in the mail address.

yum install sendmail-cf

/etc/mail/sendmail.cf

# Relay all non-local mail to the "Smart" relay host (DS) via smtp:
# This macro is optional. If you wish to send all non-local mail
# to a smart relay via SMTP just set macro S (DS) to the name of the
# smart relay. If this macro is not set, then all mail addresses to
# a non-local user will be send to the relay. #
.
.
.
# "Smart" relay host (may be null)
DShostname.domain

In recognition of the complexity of the /etc/mail/sendmail.cf file, a much simpler file named /etc/sendmail.mc was created, and it contains more understandable instructions for systems administrators to use. These are then interpreted by a number of macro routines to create the sendmail.cf file. After editing sendmail.mc, you must always run the macros and restart sendmail for the changes to take effect.

[root@test mail]# cat ~/activate-sendmail.sh #run this after modify /etc/mail/sendmail.mc
#!/bin/bash
cd /etc/mail
/usr/bin/make
/usr/bin/newaliases
service sendmail restart

newaliases #run this after modify /etc/aliases

Configuring the /etc/mail/access file will not stop spam coming to you, only spam flowing through you.

[root@bigboy tmp]# tail -f /var/log/maillog

PS:

More info about mail/sendmail can be found here

Categories: IT Architecture, Linux, Systems Tags: ,