# Configuring mail



## adripillo (Jun 7, 2013)

Hello all, I was seeing this post http://forums.freebsd.org/showthread.php?t=16268. Seems to be simple to send a mail from console, my question is where I can configure the mail? Like set the mail server address, IMAP, SMTP and all the rest. Thanks again.


----------



## wblock@ (Jun 7, 2013)

The mail server address is set by running `# cd /etc/mail; make` then editing the _hostname_.mc file it creates.  In that file, it's described as a "smarthost".  Then the file is installed with `# make all install`.

IMAP and other settings are the domain of a Mail User Agent, which you'll have to install separately from ports.  Common examples are mail/mutt and mail/alpine.


----------



## adripillo (Jun 10, 2013)

wblock@ said:
			
		

> The mail server address is set by running `# cd /etc/mail; make` then editing the _hostname_.mc file it creates.  In that file, it's described as a "smarthost".  Then the file is installed with `# make all install`.
> 
> IMAP and other settings are the domain of a Mail User Agent, which you'll have to install separately from ports.  Common examples are mail/mutt and mail/alpine.



Thanks. Inside the file next to "smarthost" there is a place where it says "your.isp.mail.server", here I need to put my full email address or just what it goes after "@" ?.


----------



## DutchDaemon (Jun 10, 2013)

A mail server is not an email address or email domain. It is something like smtp.isp.com or mail.yourprovider.com. Your ISP's helpdesk (or FAQ on their website) will tell you.


----------



## adripillo (Jun 10, 2013)

DutchDaemon said:
			
		

> A mail server is not an email address or email domain. It is something like smtp.isp.com or mail.yourprovider.com. Your ISP's helpdesk (or FAQ on their website) will tell you.



Thanks, mine is smail."something"."something".ar

I have another question, to configure the email address and the password, I can use alpine and then that configuration will be taken to send email using shel?


----------



## wblock@ (Jun 10, 2013)

An MUA is not needed at all to just send mail from the shell.  The mail(1) program can do that.  There must be a working MTA running to deliver that mail, though.


----------



## ondra_knezour (Jun 10, 2013)

adripillo said:
			
		

> ...to configure the email address and the password, I can use alpine and then that configuration will be taken to send email using shell?.



No, you will just send mail, local user doesn't have to authenticate. See mail() manual page. No Mail User Agent is required to get this working. If you want little more comfort, Handbook chapter Using mail is good start.


----------



## ondra_knezour (Jun 10, 2013)

To clarify things little - user can send message using mail program or some kind of text/graphical interface like mutt or alpine locally or let say for example Thunderbird remotely. Those programs are called MUA - Mail User Agents. Authentication is usually required for remote connection as spam prevention. This message is given to Mail Transfer Agent, MTA, on FreeBSD is sendmail default. MTA will send such message to MTA running on target system or its smarthost for delivery. This MTA will store message somewhere based on system configuration or give it to Local Delivery Agent, LDA, to process it further and store it in given location. User on target system can access those messages locally using his MUA or remotely, but for remote connection is required to have some server running, typically POP3 or IMAP.


----------



## adripillo (Jun 10, 2013)

DutchDaemon said:
			
		

> A mail server is not an email address or email domain. It is something like smtp.isp.com or mail.yourprovider.com. Your ISP's helpdesk (or FAQ on their website) will tell you.



So if I make this, an email should be sent?


```
# mail -v -s "Hello" mail@gmail.com
Hello, im just testing
.
.
EOT
.
.
.
.
.
WARNING: local host name (host) is not qualified; see cf/README: WHO AM I?
mail@gmail.com... Connecting to [127.0.0.1] via relay...
220 host ESMTP Sendmail 8.14.5/8.14.5; Mon, 10 Jun 2013 12:32:14 -0300 (ART)
>>> EHLO host
250-host Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From:<user@host> SIZE=74
250 2.1.0 <user@host>... Sender ok
>>> RCPT To:<mail@gmail.com>
>>> DATA
250 2.1.5 <mail@gmail.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 r5AFWETh064913 Message accepted for delivery
mail@gmail.com... Sent (r5AFWETh064913 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 host closing connection
```


----------



## ondra_knezour (Jun 10, 2013)

It depends, because messages from hosts or domains without valid DNS entries may be discarded, but generally it can work. Check your /var/log/maillog, there should be visible SMTP session between your server and defined smarthost.


----------



## adripillo (Jun 10, 2013)

ondra_knezour said:
			
		

> It depends, because messages from hosts or domains without valid DNS entries may be discarded, but generally it can work. Check your /var/log/maillog, there should be visible SMTP session between your server and defined smarthost.



All Logs says at the end:


```
Connection refused by alt4.gmail-smtp-in.l.google.com
```


----------



## wblock@ (Jun 10, 2013)

This is where the smarthost comes in.  That's your ISP's mail server.  After you modified _hostname_.mc and built it, restart the mail server:

```
# cd /etc/mail
# make all install restart
```

Some ISPs require authentication to use their mail server, although they generally don't allow anyone who knows how it works to talk to customers.


----------



## adripillo (Jun 10, 2013)

wblock@ said:
			
		

> This is where the smarthost comes in.  That's your ISP's mail server.  After you modified _hostname_.mc and built it, restart the mail server:
> 
> ```
> # cd /etc/mail
> ...



I tried again and with hotmail too, but also refused.


----------



## adripillo (Jun 10, 2013)

Tried this:


```
# tcptraceroute 173.194.70.27
Selected device em0, address 16.16.16.16, port 47378 for outgoing packets
Tracing the path to 173.194.70.27 on TCP port 80, 30 hops max
 1  router.xx.xx.xx.ar (GateWay IP)  9.305 ms  9.670 ms  9.990 ms
 2  fa-in-f27.1e100.net (173.194.70.27) [closed]  9.988 ms  9.697 ms  9.979 ms
# tcptraceroute 209.85.227.27 25
Selected device em0, address 16.16.16.16, port 27391 for outgoing packets
Tracing the path to 209.85.227.27 on TCP port 25, 30 hops max
 1  router.xx.xx.xx.ar (GateWay IP)  9.484 ms  9.627 ms  9.988 ms
 2  209.85.227.27 (209.85.227.27) [closed]  9.998 ms  9.823 ms  9.995 ms
```


----------



## wblock@ (Jun 10, 2013)

Just to make sure it is clear: you will almost certainly not be able to send directly to anywhere outside your ISP's network unless you have a static IP address and working reverse DNS.  The mail server on the other end will refuse.  So send to your local smarthost, which will then relay it to the destination.


----------



## adripillo (Jun 10, 2013)

wblock@ said:
			
		

> Just to make sure it is clear: you will almost certainly not be able to send directly to anywhere outside your ISP's network unless you have a static IP address and working reverse DNS.  The mail server on the other end will refuse.  So send to your local smarthost, which will then relay it to the destination.



I have a static IP inside my LAN, do not know if I have working reverse DNS in this place.

Can you please explain to me a little more about sending to my local smarthost to re-deliver?. Thanks.


----------



## adripillo (Jun 10, 2013)

I tested sending email to my "local work email" and it arrives fine. Need to find a way to re-deliver to my *G*mail. Thanks a lot to all*.*


----------



## ondra_knezour (Jun 10, 2013)

See the following pages about smarthost settings. The last one contains required info if you have to authenticate to your ISP mail server.
http://lists.freebsd.org/pipermail/freebsd-questions/2004-February/035329.html
http://systems.takizo.com/2010/09/09/setup-sendmail-smart-relay-in-freebsd/
http://www.dnsexit.com/support/mailrelay/sendmail.html

It should be as easy as transforming the default example

```
dnl define(`SMART_HOST', `your.isp.mail.server')
```
to (note _dnl_ missing)

```
define(`SMART_HOST', `snail.whateweryougot.ar')
```


----------



## adripillo (Jun 10, 2013)

ondra_knezour said:
			
		

> See the following pages about smarthost settings. The last one contains required info if you have to authenticate to your ISP mail server.
> http://lists.freebsd.org/pipermail/freebsd-questions/2004-February/035329.html
> http://systems.takizo.com/2010/09/09/setup-sendmail-smart-relay-in-freebsd/
> http://www.dnsexit.com/support/mailrelay/sendmail.html
> ...



Thanks again, this is solved. All worked fine now.


----------

