Setting up Mail Server

Ok, I don't really know where to start. I got my new internet connection today so I can setup my mail server. I have roundcube installed for checking my mail. I have imap installed and can log into it with roundcube. I used this link:
http://www.puresimplicity.net/~hemi/freebsd/sendmail.html
now I tried to use the sendmail setup on the same page but when I got to step 4 "make install" I get this error:
Code:
install -s -o root -g smmsp -m 2555 sendmail /usr/libexec/sendmail
install: sendmail: No such file or directory
*** Error code 71

Stop in /usr/src/usr.sbin/sendmail.

Now I also have port 25, 143, 110, 465, 587, 993, 995 forwarded to my server because a few different sites talk about different ports so i figured i would forward them all until i figured out which ones i exactly need.

when I reboot the system I get these errors, and I have the saslauthd_enable & sendmail_enable both set for yes in the rc.conf:
Code:
Starting sendmail.
Jun 5 17:50:15 blurr-ink sm-mta[1000]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MSA: cannot bind: Address already in use
Jun 5 17:50:15 blurr-ink sm-mat[1000]: daemon MSA: problem creating SMTP socket
Starting inetd.
Starting background file system checks in 60 seconds.

Fri Jun 5 17:50:16 EDT 2009
Jun 5 17:50:16 blurr-ink inetd[1051]: pop3s/tcp: bind: Address already in use
Jun 5 17:50:16 blurr-ink inetd[1051]: imaps/tcp: bind: Address already in use

In my inetd.conf I have only the imap and pop3 lines un-commented:
Code:
pop3  stream tcp nowait root /usr/local/libexec/ipop3d  ipop3d
imaps stream tcp nowait root /usr/local/libexec/imapd   imapd

In my DNS record I have this for my mail records (I seen it this way on another site when i couldn't get it working....):
Code:
;MX record (mail server)
IN   MX 10 mx.blurr-ink.com
IN   MX 20 mail.blurr-ink.com
IN   A     216.84.134.244 

;Aliases
mx   IN  A  216.84.134.244 
mail IN  A  216.84.134.244

When I do a port scan it says from http://www.t1shopper.com/tools/ it says:
Code:
216.84.134.244 isn't responding on port 25 (smtp).
216.84.134.244 isn't responding on port 110 (pop3).
216.84.134.244 isn't responding on port 465 (smtps).
216.84.134.244 isn't responding on port 587 (submission).
216.84.134.244 is responding on port 993 (imaps).
216.84.134.244 is responding on port 995 (pop3s).

So, I guess Im very lost...If someone could possibly point me in the right direction I would really appreciate it.

Also I changed the Ip of my server today because of the new net connection and it hasn't fully changed over would this make a difference?
 
I assume you have a fixed IP address. Do you have reverse DNS?

I am not even getting your post. Are you trying to configure a real mail server?
Who cares about roundcube, IMAP and POP. You have to be firstly able to send and receive the mail directly to your mail server. Actually, as long as you do have proper MX record, static IP and reverse DNS your sendmail server will correctly send mail. It will correctly send e-mail even without static IP, reverse DNS and MX record. The another story is that nobody is crazy enough to receive such an e-mail.

In reality, you just need to configure sendmail daemon to correctly receive e-mail. There is whole section in the Handbook on that.

http://www.freebsd.org/doc/en/books/handbook/mail.html

You probably want to configure Clamav and spamassassin before
you allow your mail server to be on 24/7 because I have a bad feeling that you will become spam zombie and lose your internet service forever.
 
what Im trying to do is setup a mail server so I can use email addresses from my site/server. Im running my nameserver/apache for my TLD and want to handle mail aswell. so blurr-ink.com is my website, and my email would be Dan@blurr-ink.com

I did plan on installing both of those programs, but how can someone spam out of my server If im the only person sending emails from it? is that even possible, If i am the only person with an account??

Um I didn't have the reverse dns setup, do those entries go in the normal hosts file with the other entries or in a separate file?

My ip isn't static but the lease is long enough that even if i have to reboot the router I keep the same IP. Although, i believe i can request a static ip.

ouch.. ok didn't realize I needed to contact my ISP about it...So it won't work atall until i get that setup?
 
If you want to send email out, use your ISP's mail server, or instruct Sendmail to use your ISP's mail server using the SmartHost directive. Sending mail from a listed/known dynamic IP address will cause your email to not be accepted by a large amount of mail servers using spam filters incorporating blacklists like Spamhaus and many others. Receiving email is another thing; there are dynamic DNS providers that can help you keep your MX records updated after an IP change, or you can script an update of your own DNS records if you have access to your zone files. Don't underestimate running a public mail server (incoming or outgoing) nowadays, there's a lot involved.
 
On a related note, new users may find Postfix as easy to use server. DutchD is right about email servers. Most mail server won't talk to you until and unless you've FQDN that matches your RDNS entry.
 
ok, thanks for the info everyone, so is it still fine that im using the FQDN that is the generated one for blurr-ink.com like the ones i've generated? (same ones for webmin and such)

So If i was using my ISP's mail server to send my mail would it still show as coming from say Lego@blurr-ink.com or would it say username@provider.net, And how would i set it up for this?

Also, if I chose that route, how could i configure my server to atleast accept mail for *@blurr-ink.com? because I've not been able to even do that.

this is my access file:
Code:
cyberspammer.com     505 we do not accept mail from spammers
FREE.STEALTH.MAILER@ 505 we do not accept mail from spammers
127.0.0.1            OK

Is that correct? or should they say REJECT?
 
There are basically three kinds of ISPs when it comes to relaying your email:

1. You're in my IP range, go ahead
2. You're in my IP range, but you must use username@provider.domain, screw you and your domain
3. You must authenticate, then you can do whatever you like

You'll have to find out what your ISP is like.

Accepting email is a different subject. You'll have to look into things like /etc/mail/local-host-names, /etc/mail/virtusertable, and many other things. Take a look at /usr/src/contrib/sendmail/cf/README for that kind of stuff.
 
well, it turns out my bill is going to double for me to change over to a static IP with reverse DNS setup. So, I guess, I won't be setting it up just yet. $85CAN.

But, the person I talked to did say I should be able to relay the mail through my providers mail server, only becasue Im a member of that provider. they gave me the name "out.mnsi.net" or was it "out@mnsi.net" so Im not quite sure how this helps. but they said it should be recieved by my domain instead of showing @out.mnsi.net or whatever. so i believe thats the option 1 from your list.

How will I setup my sendmail to relay like this? Then, next would be setting up to recieve mail for my domain, with that ip updates script could I get some help with that. Please.
 
For sending mail through your ISP, see this thread, post #4 and up, for SmartHost'ing. Use 'out.mnsi.net' as the smarthost, and it should work.

If you want to relay mail coming from your LAN, put the IP addresses/range of your LAN in /etc/mail/access with RELAY as the second filed, and run make in /etc/mail. Note, access only supports IP addresses in 'classful form' (123, 123.123, 123.123.123, 123.123.123.123), nothing in between (like 123.123.123.128/25), and no ranges (123.123.123.123-125). See http://www.sendmail.org/documentation/configurationReadme for details.

Use docs at http://www.sendmail.org/documentation/installGuide for further help.

I'm not up to speed with dynamic DNS stuff. There's bound to be stuff in ports for that.
 
ok leaving the inbound mail alone for a sec what would you recommend me doing at this point for outbound because I just added the smart host directive line in the blurr-ink.com.mc, make, make install, now I have the sendmail.cf. I restarted sendmail and tried to send out, composed a message with roundcube, but in my root mail box I keep getting postmaster messages for hotmail and yahoo not accepting mail.. so something has to be setup wrong still.
 
/var/log/maillog should give you some ideas. Did the mail actually get sent to your ISP? What's the error message from Yahoo/Hotmail? Is your From address correct? Stuff like that.
 
um yes most of it looks correct I guess, here let me show you.
just sent another message to both my email address one at yahoo the other at hotmail, sent with webmin. now i noticed it says send from localhost.blurr-ink.com instead of lego@blurr-ink.com is that an issue?
recieved this in root mailbox:
Code:
From 	Mail Delivery Subsystem <MAILER-DAEMON>
To 	postmaster
Date 	Tue, 9 Jun 2009 19:23:13 -0400 (EDT)
Subject 	Postmaster notify: see transcript for details
Code:
The original message was received at Tue, 9 Jun 2009 19:16:52 -0400 (EDT)
from localhost.blurr-ink.com [127.0.0.1]

   ----- The following addresses had permanent fatal errors -----
<champagne_dan@hotmail.com>
    (reason: 550 DY-001 Mail rejected by Windows Live Hotmail for policy reasons.
We generally do not accept emai...l/network admins, please visit http://postmaster.live.com
for email delivery information and support)

   ----- Transcript of session follows -----
... while talking to mx3.hotmail.com.:
>>> MAIL From:<Lego@blurr-ink.com> SIZE=661
<<< 550 DY-001 Mail rejected by Windows Live Hotmail for policy reasons. We generally
do not accept email from dynamic IP's as they are not typically used to deliver unauthenticated
SMTP e-mail to an Internet mail server. http://www.spamhaus.org maintains lists of
dynamic and residential IP addresses. If you are not an email/network admin please
contact your E-mail/Internet Service Provider for help. Email/network admins, please
visit http://postmaster.live.com for email delivery information and support
554 5.0.0 Service unavailable
... while talking to b.mx.mail.yahoo.com.:
<<< 553 Mail from 216.8.134.244 not allowed - 5.7.1 [BL21] Connections not accepted
from IP addresses on Spamhaus PBL; see http://postmaster.yahoo.com/550-bl21.html
[550]
... while talking to f.mx.mail.yahoo.com.:
<<< 553 5.7.1 [BL21] Connections not accepted from 216.8.134.244 due to being on
Spamhaus; see http://postmaster.yahoo.com/550-bl23.html
451 4.4.1 reply: read error from a.mx.mail.yahoo.com.
... while talking to c.mx.mail.yahoo.com.:
<<< 553 Mail from 216.8.134.244 not allowed - 5.7.1 [BL21] Connections not accepted
from IP addresses on Spamhaus PBL; see http://postmaster.yahoo.com/550-bl21.html
[550]
... while talking to d.mx.mail.yahoo.com.:
<<< 553 Mail from 216.8.134.244 not allowed - 5.7.1 [BL21] Connections not accepted
from IP addresses on Spamhaus PBL; see http://postmaster.yahoo.com/550-bl21.html
[550]
... while talking to g.mx.mail.yahoo.com.:
<<< 553 Mail from 216.8.134.244 not allowed - 5.7.1 [BL21] Connections not accepted
from IP addresses on Spamhaus PBL; see http://postmaster.yahoo.com/550-bl21.html
[550]
451 4.4.1 reply: read error from e.mx.mail.yahoo.com.
<champagne_dan@yahoo.ca>... Deferred: Name server: e.mx.mail.yahoo.com.: host name
lookup failure
550 5.1.1 <Lego@blurr-ink.com>... User unknown

Also, I was just looking at my Security run output, and found this:
Code:
Checking setuid files and devices:

Checking for uids of 0:
root 0
toor 0

Checking for passwordless accounts:

Checking login.conf permissions:

blurr-ink.com kernel log messages:
+++ /tmp/security.bLhuET5m	2009-06-09 03:01:12.000000000 -0400
+ral0: link state changed to DOWN
+ral0: link state changed to UP

blurr-ink.com login failures:
Jun  8 06:10:04 blurr-ink sshd[58448]: Invalid user admin from 209.55.103.88
Jun  8 06:10:07 blurr-ink sshd[58452]: Invalid user stud from 209.55.103.88
Jun  8 06:10:08 blurr-ink sshd[58454]: Invalid user trash from 209.55.103.88
Jun  8 06:10:10 blurr-ink sshd[58456]: Invalid user aaron from 209.55.103.88
Jun  8 06:10:11 blurr-ink sshd[58458]: Invalid user gt05 from 209.55.103.88
Jun  8 06:10:12 blurr-ink sshd[58460]: Invalid user william from 209.55.103.88
Jun  8 06:10:14 blurr-ink sshd[58462]: Invalid user stephanie from 209.55.103.88
Jun  8 06:10:22 blurr-ink sshd[58474]: Invalid user gary from 209.55.103.88
Jun  8 06:10:25 blurr-ink sshd[58478]: Invalid user guest from 209.55.103.88
Jun  8 06:10:26 blurr-ink sshd[58480]: Invalid user test from 209.55.103.88
Jun  8 06:10:27 blurr-ink sshd[58482]: Invalid user oracle from 209.55.103.88
Jun  8 18:02:36 blurr-ink sshd[68932]: Invalid user oracle from 211.38.137.44
Jun  8 18:02:39 blurr-ink sshd[68934]: Invalid user test from 211.38.137.44

blurr-ink.com refused connections:

-- End of security output --

Is that someone trying to hack my ssh??
 
oh and here is my tail /var/log/maillog:
Code:
blurr-ink# tail /var/log/maillog
Jun  9 19:14:37 blurr-ink sendmail[5342]: n59NEbCu005342: <Lego@blurr-ink.com>... User unknown
Jun  9 19:14:37 blurr-ink sendmail[5342]: n59NEbCu005342: from=<champagne_dan@yahoo.ca>, size=0, class=0, nrcpts=0, proto=SMTP, daemon=IPv4, relay=web53201.mail.re2.yahoo.com [206.190.49.71]
Jun  9 19:15:20 blurr-ink imapd[5346]: Login user=Lego host=dyn216-8-134-244.ADSL.mnsi.net [216.8.134.244]
Jun  9 19:15:20 blurr-ink imapd[5346]: Logout user=Lego host=dyn216-8-134-244.ADSL.mnsi.net [216.8.134.244]
Jun  9 19:16:20 blurr-ink imapd[5368]: Login user=Lego host=dyn216-8-134-244.ADSL.mnsi.net [216.8.134.244]
Jun  9 19:16:20 blurr-ink imapd[5368]: Logout user=Lego host=dyn216-8-134-244.ADSL.mnsi.net [216.8.134.244]
Jun  9 19:16:52 blurr-ink sendmail[5371]: n59NGqbM005371: from=Lego@blurr-ink.com, size=491, class=0, nrcpts=2, msgid=<1244589412.5369@blurr-ink.com>, relay=root@localhost
Jun  9 19:16:52 blurr-ink sm-mta[5372]: n59NGqej005372: from=<Lego@blurr-ink.com>, size=661, class=0, nrcpts=2, msgid=<1244589412.5369@blurr-ink.com>, proto=ESMTP, daemon=Daemon0, relay=localhost.blurr-ink.com [127.0.0.1]
Jun  9 19:16:52 blurr-ink sendmail[5371]: n59NGqbM005371: to=champagne_dan@hotmail.com,champagne_dan@yahoo.ca, ctladdr=Lego@blurr-ink.com (1001/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=60491, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (n59NGqej005372 Message accepted for delivery)
Jun  9 19:16:53 blurr-ink sm-mta[5374]: n59NGqej005372: to=<champagne_dan@hotmail.com>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=60661, relay=mx3.hotmail.com. [65.54.244.200], dsn=5.0.0, stat=Service unavailable
blurr-ink#
 
Yes, people will always try to hack your sshd. Welcome to the net. See http://forums.freebsd.org/showthread.php?t=4108 for tips.

Your mail is not going through your ISP's mail server, so it gets rejected because it comes from your dynamic IP address. Look into the smarthost stuff again. It should show up in sendmail.cf as "DSout.mnsi.net" if you did it right.
 
Ok, this is ridiculous. I think I'm going to change the port which ssh connects on because I just checked the security run for yesterday/last night, whichever it is, and I have had an insane amount of log attempts. Thanks for that link with the security info. And I'll look into the SmartHost again, and get back to ya, Thanks. How would I add the mail as an attachment to my post, because I can't find the actual document in my /var/mail folder. I just wanted to add it and show you the like 500+ log attempts.
about 250 like this:
Code:
[212.154.32.188] failed - POSSIBLE BREAK-IN ATTEMPT!
Jun  9 18:07:12 blurr-ink sshd[3992]: Invalid user ftpuser from 212.154.32.188
another 250 or so like this:
Code:
Jun  9 12:36:10 blurr-ink sshd[86692]: Invalid user nagios from 213.159.6.144
and 3 like this:
Code:
Jun  9 09:58:46 blurr-ink proftpd[83436]: localhost.blurr-ink.com (www.eclic-visio.com[88.191.61.58])
- USER mysql (Login failed): Incorrect password.

I tried to track the IP like I did that other ones, but these come up with nothing but question marks.
 
Not only very secure passwords (or only ssh keys in the case of sshd), but 'unusual' usernames as well. Anything straight out of a dictionary, or almost any conceivable first or last name, animal name, vegetable, fruit, and possibly insect, is in every rainbow table out there.
 
hmm.. well my passwords all incorporates numbers, letters, and special characters, as for my usernames those vary from item to item.. like my username for webmin is different then the system, and different from mysql, and so on.. so if someone manages to get 1 username/password match, thats the only thing its good for. and none of the usernames/passwords incorporate my real name or screen name.

Is it 'wrong' to contact the provider of the IP and tell them that someone in there service has been attempting to hack my server? because Im sure they have records of who has been issued what IP, correct? And maybe even provide the log of attempts?
 
YAY!! I was able to send a message to hotmail after re-reading and doing the process again now I'm just waiting to see if my yahoo account will receive a mail aswell. *It did, but was sent to the spam mail folder

Unfortunately, this morning I released my IP and tried to change ports for ssh, but when I edited the sshd_config and un commented the Port line and changed the port number my server wouldn't connect http/ftp/ssh none so i changed it back and rebooted the server again, and its not working again :S.

Now I will probably have to wait until my dns finishing resolving but will my incoming mail just work automatically now?

ssh is working agian.
 
Yes, I think so, but it may be 'by accident'.

Your server has the same name as your domain, and I guess your email address (the part before @) is also a local mailbox. Your email address is therefore "mailbox@server". That's by far the simplest Sendmail setup there is, and it should work because there's nothing virtual about it. And your MX record is pointing to the IP address of the server, I presume, so you should be good to go for now.

If you need to handle email for more domains you will have to look into virtusertable and local-host-names. And if you need to receive mail for addresses that are not local mailbox names, aliases can help you out -- though in that case I would go for virtusertable straight away.
 
hmm.. well I had setup some of that stuff while I was following a sendmail setup tutorial. how do I stop it from being sent to the yahoo spam folder?
/etc/mail/access
Code:
cyberspammer.com    505 we do not accept mail from spammers
FREE.STEALTH.MAILER@505 we do not accept mail from spammers
127.0.0.1           OK

/etc/mail/aliases is default

/etc/mail/local-host-names
Code:
blurr-ink.com

/etc/mail/mailer.conf is default

/etc/mail/virtusertable
Code:
root@blurr-ink.com       root
Lego@blurr-ink.com       Lego
admin@blurr-ink.com      Lego
@blurr-ink.com           Lego

DNS record:
Code:
;MX record (mail server)
IN   MX 10 mx.blurr-ink.com
IN   MX 20 mail.blurr-ink.com
IN   A     216.84.134.244 

;Aliases
mx   IN  A  216.84.134.244 
mail IN  A  216.84.134.244

Is that all correct? Like in the setup
 
Lego said:
/etc/mail/virtusertable
Code:
root@blurr-ink.com       root
Lego@blurr-ink.com       Lego
admin@blurr-ink.com      Lego
@blurr-ink.com           Lego
You can remove the Lego@ and admin@ entries, because the @blurr-ink.com entry already points to mailbox Lego. Note that this creates a 'catch-all' situation. In other words: any email address on your domain is acceptable and will be delivered to your mailbox. If you want to lock down the email addresses you want to handle, lose the @blurr-ink.com line, and only define the exact email addresses you want to accept.
Lego said:
DNS record:
Code:
;MX record (mail server)
IN   MX 10 mx.blurr-ink.com
IN   MX 20 mail.blurr-ink.com
IN   A     216.84.134.244 

;Aliases
mx   IN  A  216.84.134.244 
mail IN  A  216.84.134.244

Having two MX records pointing to the same address does not add any value. Just pick one. Note that you should add the hostname you're using in an MX record to local-host-names. RFCs state that you should have a working postmaster address on any MX hostname. So if you go with mail.blurr-ink.com, add mail.blurr-ink.com to local-host-names, and postmaster@mail.blurr-ink.com to virtusertable.

Note that a change to local-host-names requires a restart of Sendmail, whereas databases like aliases, virtusertable, mailertable etc. require 'make' in /etc/mail.
 
ok ok, thanks. so should I leave the blurr-ink.com in the localhosts names and add mx.blurr-ink.com or just have mx.blurr-ink.com?

I will remove the dns entry for mail.blurr-ink.com and just use the mx record.

Add postmaster@mx.blurr-ink.com to virtusertable. then "cd /etc/mail && make" then will I have to copy the blurr-ink.com.cf to sendmail.cf and blurr-ink.com.mc to sendmail.mc again?? then restart sendmail
 
If you're using virtusertable you must include all domains and hostnames in local-host-names. Then restart sendmail ([cmd=]/etc/rc.d/sendmail restart[/cmd]). You should also put corresponding entries in virtusertable to handle email addresses under those domains/hostnames.

Changes to any of the tables in /etc/mail (aliases, access, virtusertable, mailertable, etc.) only require you to run 'make' in /etc/mail. You don't need to restart Sendmail for that -- the changes are active right after 'make'.

The only time when sendmail.cf needs to be regenerated is when you actually make changes to Sendmail itself -- i.e. turning on/off certain options, adding/removing plugins like Spamassassin, Milter etc, when changing your server's hostname, when switching to a different smarthost (i.e.: changes to the .mc file), etc.
 
Back
Top