Archive for the Mail Server Basics Category

Sending non-FQDN Mail to Your Mail Server

Posted by Filed Under Mail Server Basics with Comments Off

Sending Mail from Server Scripts

Often when an administrator tries to send the results of a script from a server to a user on the mail server for the company the email is rejected. One of the reasons this happens is that the server that is sending the mail does not have

a Fully Qualified Domain Name (FQDN), either because it was never set or because DNS cannot resolve to this IP Address as it is behind a firewall. The other reason for the failure is that the mail server specifically is designed to drop both non-FQDN hostnames or drop invalid hostnames.

The rules are that each valid hostname should contain a top level domain (com,net,com, etc), a domain, like example in example.com and it should contain a “.” separating the two. Both of these settings are indications of SPAM. Here is what the smtpd restrictions look like on a Postfix mail server.  Note: All lines must be indented after the “=”, WordPress just will not recognize an empty space.

smtpd_recipient_restrictions =
permit_mynetworks
reject_unauth_destination
reject_non_fqdn_hostname
reject_invalid_hostname
permit

This image illustrates the problem. The database server sending the mail from a generated script is a legitimate server to send mail, but since it does not have a Fully Qualified Domain Name (FQDN) the mail is rejected because of the two recipient restrictions:

reject_non_fqdn_hostname
reject_invalid_hostname

Log Entries Demonstrating Rejection

Oct 4 11:32:42 mail postfix/smtpd[30870]: connect from example.com[192.168.0.1]
Oct 4 11:32:42 mail postfix/smtpd[30870]: warning: Unable to look up MX host for srv2.example.com: Host not found
Oct 4 11:32:42 mail postfix/cleanup[30874]: B0966D0C8A: message-id=<20111004113242.B0966D0C8A@mail.example.net>
Oct 4 11:32:42 mail postfix/qmgr[22286]: B0966D0C8A: from=<postmaster@example.net>, size=298, nrcpt=1 (queue active)
Oct 4 11:32:42 mail postfix/smtp[30875]: B0966D0C8A: to=<mike@srv2.example.com>, relay=none, delay=0.01, delays=0/0.01/0/0, dsn=5.4.4, status=undeliverable (Host or domain name not found. Name service error for name=srv2.example.com type=A: Host not found)
Oct 4 11:32:42 mail postfix/qmgr[22286]: B0966D0C8A: removed
Oct 4 11:32:45 mail postfix/smtpd[30870]: NOQUEUE: reject: RCPT from example.com[192.168.0.1]: 450 4.1.7 <mike@srv2.example.com>: Sender address rejected: undeliverable address: Host or domain name not found. Name service error for name=srv2.example.com type=A: Host not found; from=<mike@srv2.example.com> to=<mike@example.net> proto=ESMTP helo=<srv2.example.com>
Oct 4 11:32:45 mail postfix/smtpd[30870]: disconnect from example.com[192.168.0.1]

The solution is easy to perform. Add the database server IP Address to the mynetworks parameter in main.cf.

mynetworks = 127.0.0.0/8, 192.168.0.1

Restart Postfix and you are ready to go.

Whether the mail server is Postfix, Sendmail, Exim, or Exchange they all have settings which allow exceptions like the above mentioned.

Log Entries Demonstrating Solution

Oct 4 11:36:17 mail postfix/smtpd[30902]: connect from localhost[127.0.0.1]
Oct 4 11:36:17 mail postfix/smtpd[30902]: 18AF2D0C8D: client=localhost[127.0.0.1]
Oct 4 11:36:17 mail postfix/cleanup[30897]: 18AF2D0C8D: message-id=<20111004113603.GB15654@srv2.example.com>
Oct 4 11:36:17 mail postfix/qmgr[30892]: 18AF2D0C8D: from=<mike@srv2.example.com>, size=1188, nrcpt=1 (queue active)
Oct 4 11:36:17 mail amavis[9320]: (09320-01) Passed CLEAN, [184.106.215.97] [184.106.215.97] <mike@srv2.example.com> -> <mike@example.net>, Message-ID: <20111004113603.GB15654@srv2.example.com>, mail_id: sw1H7xdMgUHv, Hits: 1.179, size: 682, queued_as: 18AF2D0C8D, 9490 ms
Oct 4 11:36:17 mail postfix/smtp[30898]: 45DCAD0C8A: to=<mike@example.net>, relay=127.0.0.1[127.0.0.1]:10024, delay=10, delays=0.11/0.01/1.1/8.9, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 18AF2D0C8D)
Oct 4 11:36:17 mail postfix/qmgr[30892]: 45DCAD0C8A: removed
Oct 4 11:36:17 mail postfix/local[30903]: 18AF2D0C8D: to=<mike@example.net>, relay=local, delay=0.64, delays=0.08/0.52/0/0.04, dsn=2.0.0, status=sent (delivered to mailbox)
Oct 4 11:36:17 mail postfix/qmgr[30892]: 18AF2D0C8D: removed

Managing Mailbox Size

Posted by Filed Under Mail Server Basics with Comments Off

There are default mailbox sizes which may lead to mail delivery failure when you go beyond the defaults.  In order to avoid problems you need to understand the difference between mailboxes and virtual_mailboxes as well as know the default sizes and how to adjust them.

Here is the error that you want to avoid:

mailbox /var/spool/vmaill/vmail/1: error

writing message: File too large

Mailbox Size Limit
Default mailbox size is 50 MB.  This means that if your mailbox goes beyond 50 MB, you will need to adjust the default or you will see the error, “File too large”.
The limit for any local mailbox or maildir is 50 MB but,  this can easily be changed with by using this directive in the main.cf file.  Be sure to restart Postfix if you make changes.

mailbox_size_limit=102400000

This changes the mailbox limit to 100 MB.  Or you can make it umlimited by using a “0″.

mailbox_size_limit=0

If you would like to review the current settings on your Postfix server use this command:

postconf -d | grep size
berkeley_db_create_buffer_size = 16777216
berkeley_db_read_buffer_size = 131072
body_checks_size_limit = 51200
bounce_size_limit = 50000
header_size_limit = 102400
mailbox_size_limit = 51200000
message_size_limit = 10240000


Message Size Limit
message_size_limit = 20480000

This is 20 MB.

Virtual Mailbox Limit
Note that the virtual_mailbox_limit is for the virtual accounts not the local accounts which are controlled by mailbox_size_limit.  The default limit is 50 MB or 51200000

virtual_mailbox_limit=0

This is unlimited.

If you are using PHP to send mail you may need to change other parameters  in the /etc/php.ini. Modify those  parameters to a higher value as below:

post_max_size = 30M
upload_max_filesize = 30M

Be sure to use the settings that work for you and recognize that as these limits get larger they may impact more aspects of your server so test them completely.

Making Postfix the Default Mail Server

Posted by Filed Under Mail Server Basics with Comments Off

Alternatives Program for MTAs

The alternatives program is a way to change the default mail server so that it will be Postfix. This program is only necessary for CentOS not Suse or Ubuntu, as Suse and Ubuntu both use Postfix as the default.

Alternatives is a program that will allow you to assess and change the mail program or MTA options. To view current links to the program use the following command.

alternatives –display mta

mta – status is manual.

link currently points to /usr/sbin/sendmail.postfix

/usr/sbin/sendmail.sendmail – priority 90

slave mta-pam: /etc/pam.d/smtp.sendmail

slave mta-mailq: /usr/bin/mailq.sendmail

slave mta-newaliases: /usr/bin/newaliases.sendmail

slave mta-rmail: /usr/bin/rmail.sendmail

slave mta-sendmail: /usr/lib/sendmail.sendmail

slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz

slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz

slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz

slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz

/usr/sbin/sendmail.postfix – priority 30

slave mta-pam: /etc/pam.d/smtp.postfix

slave mta-mailq: /usr/bin/mailq.postfix

slave mta-newaliases: /usr/bin/newaliases.postfix

slave mta-rmail: /usr/bin/rmail.postfix

slave mta-sendmail: /usr/lib/sendmail.postfix

slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz

slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz

slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz

slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz

Current `best’ version is /usr/sbin/sendmail.sendmail.

If you wanted to change from a Sendmail MTA to Postfix MTA use this command:

alternatives –set mta /usr/sbin/sendmail.postfix.

You should not see any output.

To select an alternative from those MTAs available use this command:

alternatives –config mta

You will see this output which will allow you to choose an MTA using a number.

alternatives –config mta

There are 2 programs which provide ‘mta’.

Selection Command

———————————————–

* 1 /usr/sbin/sendmail.sendmail

+ 2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number:


Copyright CyberMontana Inc. and Postfixmail.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874

Introduction to Mail Servers

Posted by Filed Under Mail Server Basics with Comments Off

There are several different components to the email system. They work together to move, deliver or retrieve your email.

Mail Transfer Agent (MTA)

The MTA does a great deal of the hard work in moving mail around as it is responsible to move the mail from the local MTA to the destination MTA on the Internet. The Mail Transfer Agent works closely with DNS in making this all happen. The MTA uses a specific language SMTP to transfer mail on port 25, which is a standard. Several examples of MTAs are Sendmail, Postfix, and QMAIL.

Mail Delivery Agent (MDA)

The MDA will receive the mail destined for the local network from the MTA and then will make this mail available for the user. The MDA will use POP3 on port 110 or IMAP on port 143 to make this available to users. Examples of MDA are Dovecot or Cyrus-IMAP.

Mail User Agent (MUA)

The MUA is the client program that the end user uses to retrieve and view email. Users are able to view web based email with a browser but will user tools like Outlook, Thunderbird, Mutt, or Evolution to download mail to the local machine.

When you send or read your email, the only part you see is the MUA, which is a fancy way of saying email client. But, there’s a lot more than that involved. To send an email, you’ll first sit down at your computer and fire up Thunderbird, or whichever other email client that you’re using. When you compose the message and click on the send button, the MUA will send it to the MTA. (The MTA could either be on the corporate network or at your ISP.) This MTA will send the message to successive MTA’s until it gets to the MTA that serves the email recipient. This MTA will then send the message to a Post Office Protocol (POP)/Internet Mail Application Protocol (IMAP) server. This server will store the email until the recipient accesses it with her MUA. Of course, this same process could take place within a corporate network instead of across the Internet.


Copyright CyberMontana Inc. and Postfixmail.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874