# How to change mail.domain.com to mysubdomain.domain.com?



## bitsandnumbers (Jul 14, 2013)

Hi everyone,

I just took the three last days of my life setting up a mail server at home, and I finally see the end of the tunnel. But when I try to send a mail to an external address (with this command: `echo test | mail -s "First test SMTP" some @ email . org && tail -f /var/log/maillog`), I end up with an error like this: 


```
postfix/smtp[73788]: connect to mail.domain.com[70.39.97.232]:10025: Operation timed out
```

So what I would like is a way to replace the "mail" subdomain with my own, because obviously my domain does not have a mail. subdomain and I cannot add one (I'm with a free domain provider, but my domain handles A and MX records).

I'm open to suggestions 

BTW: configuration is / dnsmasq / MySQL / Postfix / Dovecot / SpamAssassin


----------



## fonz (Jul 14, 2013)

bitsandnumbers said:
			
		

> I just took the three last days of my life


Ouch. I hope not


----------



## Chris_H (Jul 17, 2013)

bitsandnumbers said:
			
		

> Hi everyone,
> 
> I just took the three last days of my life setting up a mail server at home, and I finally see the end of the tunnel. But when I try to send a mail to an external address (with this command: `echo test | mail -s "First test SMTP" some @ email . org && tail -f /var/log/maillog`), I end up with an error like this:
> 
> ...



You're going to need an additional host entry, if you want to go that route. I'm pretty sure most of the public/free outfits will allow that -- they give you WWW, don't they? Anyway, once you get an additional host name tacked on to your domain -- say MX1 -- then all you need do, is make an MX PTR to it:

```
$ORIGIN freedomain.tld.
blah,blah...

    IN  MX  20  MX1
; or
    IN  MX  20  MX1.freedomain.tld.
```
Either way, you'll need an additional host name to use as an MX (Mail Exchanger).

HTH

--chris


----------



## bitsandnumbers (Jul 18, 2013)

Chris_H said:
			
		

> ```
> $ORIGIN freedomain.tld.
> blah,blah...
> 
> ...



Thanks chris. Where should I put those config lines?

As for the MX domain, the freedns domains are like this: subdomain.domain.com, with subdomain of your choosing, and domain.com given by the service. When you add an MX record, it's added to the address you registered. So to be more precise, when you've got a subdomain.domain.com it serves both for A and for MX, there are not two separate sub/domains for each.

If I enter the lines you provided in the right file with my subdomain.domain.com, it may work.


----------



## Chris_H (Jul 18, 2013)

Greetings,

OK. Overall, this is not a trivial matter. But I'll see if we can untangle this. I could use more detail. But here goes...

Given that you will be using _their_ DNS, you will _presumably_ be entering the necessary information within forms that they provide. NOTE: I haven't seen these forms, so I will simply provide the details, in hopes that you can figure out where/how to use them. 

For the sake of this example, we will assume that your _chosen_ host name will be "freehost". We will presume that the free service provides the domain "freedomain.com". Based on that, _your_ new free domain becomes: "freehost.freedomain.com".

So, here we go! PTR/RR information you care about:

```
$ORIGIN freedomain.com.
@	IN SOA  dns.freedomain.com.	root.localhost.	(
  ; Serial
  ; Refresh
  ; Retry
  ; Expire
) ; Minimum

; the following are likely the only parts of interest to you

  IN A  123.456.789.876 ; example entry, fictitious IP address

; RFC's indicate you should have minimum of 2 MX (Mail Exchangers) entries
; Unless you have someone that will provide a backup MX for you, we will use
; a trick here, and pretend we have 2
  MX  0   freehost.freedomain.com.
  MX  99  freehost2.freedomain.com.

           IN  HINFO  AMD-PC/AT BSD/OS ; HINFO may not be an option to you
                                       ; but here in case it is
freehost   IN  A  IN A  123.456.789.876 ;redundant, but there is old broken software
freehost2  IN  CNAME  freehost
```
For clarification, should it not be obvious; *A* indicated "IP *A*ddress". *MX* indicates "*M*ail *E*xchanger. *HINFO* indicates "*H*ost *INFO* -- Hardware, and Operating System, provided by the Host.

Hopefully this will get you there. But if not, I'll be checking in from time, to time today, as work permits.

--chris


----------



## bitsandnumbers (Jul 18, 2013)

Thank you, I didn't see your post until now, sorry ^^

I need to know in which file I should put those lines to try? For now I assume my hosts file, but I'm really not sure!


----------



## bitsandnumbers (Jul 18, 2013)

Oh, and as for this line


```
freehost   IN  A  IN A  123.456.789.876 ;redundant, but there is old broken software
```
You should know that I don't have a static IP, but if you're referring to the local IP it would be more like 192.168.1.51. What should I do here?


----------



## Chris_H (Jul 19, 2013)

Greetings,

OK. This is what I meant. I _do_ need a little more info:

How are you getting a hostname?
Do they provide DNS (name resolution)?
Do they point it at your current IP?
This should give me enough clues to fill in all the other blanks. 

Best wishes.

--chris

P.S. No, it doesn't go in your hosts file. We'll get to all of that, after you answer this post (I think).


----------



## bitsandnumbers (Jul 19, 2013)

Ok, thanks. I think I can answer those questions. Tell me if I misinterpret them:

1. How are you getting a hostname?
I use the DynDNS plugin from the FreeNAS GUI.

2. Do they provide DNS (name resolution)?
No, not that I could find.

3. Do they point it at your current IP?
Yes, they point it to the IP that FreeNAS gives them through the DynDNS plugin

But here is the interesting thing: I found out when looking for a DNS provided by FreeDNS that *I* did a mistake when setting up my MX record. Here is what I put in the setup (I use your designations from earlier post):

Subdomain: freehost	
Domain:	 .freedomain.com
Destination:	10:*mail*.mooo.com
TTL:	 (not available for me)
Wildcard:	 Enabled for all subscribers (more info)

So I did put the "mail" subdomain thinking that freedomain.com had something setup to help the process... I don't know why. So I'll try and change that to see if it works.


----------



## bitsandnumbers (Jul 19, 2013)

Ok, update on this: I got things running better this time, with adjusted MX records directly from the FreeDNS website.

With this command:
`echo test | mail -s "Premier test SMTP" [email=username@freehost.freedomain.com]username@freehost.freedomain.com[/email] && tail -f /var/log/maillog`

I now get:

```
Jul 19 16:23:14 barabon postfix/smtp[5016]: D1B0856181: to=<username@freehost.freedomain.com>, relay=none, delay=0.41, delays=0.18/0.01/0.22/0, dsn=4.4.1, status=deferred (connect to freehost.freedomain.com[redacted IP]:10025: Connection refused)
```

So I assume that I misconfigured something and that port 10025 is blocked. Any idea?


----------



## Chris_H (Jul 19, 2013)

Maybe. Maybe not. There are several other possibilities, that relate directly to the questions I posed in my last response to you. A definitive conclusion depends on answers to those questions. Otherwise, we're just "groping in the dark". For example; it might be rejected based on what is perceived as a "phoney" host name -- just to mention one. SPAM is a _big_ issue these days, and postmasters go to great lengths to thwart it. If you answer my questions above, I can help you to get _real_ answers as to why your mail is, or isn't functioning in a way you perceive it should. 

--chris

P.S. You might also do well to investigate SMTP response codes. For example; 4.41 really isn't the proper response to a direct rejection. Typically it's a 5.xx. See: RFC 3461, RFC 6522, RFC 5322, and RFC 822, for all the "dirty details".


----------



## ShelLuser (Jul 19, 2013)

That looks like a bad Postfix configuration to me. Port 10025 is often used by content filters, so it looks as if Postfix was configured to use one yet it didn't run.

I'd check main.cf to see if you can find any mentioning of this port in there, optionally you might also want to go over master.cf since this file defines the several service types (amongst which content filters).


----------



## bitsandnumbers (Jul 19, 2013)

@Chris_H: I tried to respond four posts ago. You may not have seen it because it was being moderated, while the post just after went through directly. Tell me if I did not answer correctly.

@ShelLuser: I use a content filter actually. I use spamd with those services: obspamd, clamav-clamd, clamsmtpd, sa-spamd. When I grep main.cf for port 10025, I get:


```
content_filter = scan:freehost.freedomain.com:10025
```

In master.cf I added those lines:


```
smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin
spamassassin unix  -       n       n       -       -       pipe
user=nobody argv=/usr/local/bin/spamc -u mailnull -U /var/run/SpamAssassin.socket -e /usr/local/sbin/sendmail -oi -f ${sender} ${recipient}
```

So it's a setup with SpamAssassin filtering, which I'm really not acquainted with. So there could be mistakes in my setup. Anyway, this "Connection refused" certainly mean that I did not give the good rights to Postfix to access SpamAssassin ports. Whatever this is, I have no clue of what to do next.


----------



## Chris_H (Jul 20, 2013)

Ahh... I see your post now. It (clearly) wasn't there when I responded to you earlier. 


> Subdomain: freehost
> Domain: .freedomain.com
> Destination: 10:mail.mooo.com
> TTL: (not available for me)
> Wildcard: Enabled for all subscribers (more info)


OK. I can see a couple of potential issues here. But I'll get to them in a moment.

First off. As memory serves; Dyn assigns you, or you get to pick a domain name. Is that true? Oh... this just in... You're using afraid's "vanity" hosting/DNS services. Well, that throws a bit of a twist in things. You _do_ know, they let you set A, AAAA, NS, TXT, CNAME, and MX rr's on those names, don't you? My initial advice, is if you're using mooo.com, which is a "wildcard" domain. You need to make use of their (afraid's) control panel, and make the assignments, I advised you of earlier.

```
IN NS  freehost.freedomain.com ;or whatever you chose/got assigned
                               ; also presumes YOU will be running a DNS (not advised)

  IN  A  123.456.789.876

  MX  0  freehost
  MX  99  freehost2

freehost  IN  A  123.456.789.876
freehost2  IN  CNAME  freehost
```
If your chosen/assigned host/domain name is "mooo.com"

```
; mooo.com
freehost   IN  A   123.456.789.876

           MX  0   freehost
           MX  99  freehost2

freehost2  IN  CNAME  freehost
```
it is also possible, but not _yet_ advised to

```
; mooo.com
freehost    IN  A  123.456.789.876
freehost2   IN  A  123.456.789.876

            MX  0   freehost
            MX  99  freehost2
```
The last one will work fine. But you need to get a working system, before adding additional stuff, that you will need to, to accomplish the last example. Let's keep it simple, to start. 
Have you any entries in your hosts(5) file?

```
123.456.789.876    freehost.mooo.com  freehost
123.456.789.876    freehost.mooo.com
```

Please clarify any (mis)understandings I may have arrived at, and best of luck.
I'll keep a watch here for any reply. 

--chris

P.S. worst comes to worst; I can give you DNS, as I'm RP for a couple of static blocks.
But let's only try that as a last resort.


----------



## fonz (Jul 20, 2013)

Chris_H said:
			
		

> Ahh... I see your post now. It (clearly) wasn't there when I responded to you earlier.


We try to prevent this sort of thing, but occasionally it does happen.

When someone is (for whatever reason) on auto-moderation we of course try to approve (or reject, as sometimes the case may be) posts as soon as possible, but it still requires "manual labour" and occasionally it may be a while before someone is able to take care of it.

Sorry for any inconvenience.


----------



## Chris_H (Jul 20, 2013)

Hey @fonz! No problem. It's understood! 
Thanks.
--chris


----------



## bitsandnumbers (Jul 20, 2013)

@fonz: it's ok,  thanks for the hard work 

As for the matter of this thread, I found out that something in my Dovecot, Postfix setup was preventing the jail from fully loading. I'll dig into that and come back to take back from where we left. Please, if you wish to, continue to follow this thread, @Chris_H, I didn't say my last word on this matter


----------



## Chris_H (Jul 20, 2013)

bitsandnumbers said:
			
		

> Please, if you wish to, continue to follow this thread, @Chris_H, I didn't say my last word on this matter



I'll keep it in the queue. 

Good luck!

--chris


----------

