# SMTP for SMF...how to set this up?

## Warhead

Quick and dirty: I have installed the simple machines forum and now I need an MTA so the forum can send e-mails. Is there any LIGHTWEIGHT and EASY setup for this? I just have to be able to send e-mails via SMTP. No pop3, no ssl, no fancy stuff, just plain SMTP. I found nothing like that in the documentation pages and I am really lost, since I tried to configure netqmail, vpopmail and postfix, but none of it could be convinced to work.

Regards

Warhead

----------

## kashani

Setting up Postfix in five easy steps. 

1. Remove USE flags you don't need and build Postfix

```
echo "mail-mta/postfix        -ldap -mysql -postgres -ssl -sasl" >> /etc/portage/package.use

emege postfix

```

2. edit /etc/mail/aliases and point root: to a local admin user (ie you) and run newaliases

```
vi /etc/mail/aliases

newaliases

```

3. Add these lines to the bottom of your /etc/postfix/main.cf and edit the two fields with <>

```
# local settings

myhostname = $<your_fully_qualified_host_name>

mydomain = $<your_domainname>

myorigin = $mydomin

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost

mynetworks_style = subnet

mynetworks = 127.0.0.0/8

smtpd_recipient_restrictions = 

        reject_unknown_recipient_domain

        permit_mynetworks

        reject_unauth_destination

        permit

```

4. Add to default runlevel and start Postfix

```
rc-update add postfix default

/etc/init.d/postfix start

```

Dang that was only fours steps... well that's how easy it is.  :Smile: 

kashani

----------

## Warhead

Thanks for your quick answer.

I created a user called maildemon and then followed your steps. After all the postfix service starts but in the configuration of the forum I want to use I have to give the following information:

mailtype (set so smtp)

SMTPserver (i set that to localhost)

SMTPport (let that on 25)

smtp username (uses the name of my user there)

smtp password (was nut sure, used the accountpasword of the user)

When the forum tries to send an e-mail it fails with the error (according to the forums log):

Couldn't get mail server response codes

SO I guess I misconfigured something, but I do not see it.

Regards

Warhead

----------

## kashani

You shouldn't need any usernames and passwords to send mail. Try removing those.

kashani

----------

## Warhead

Well, partly a success...no error messages in the forum log, but none of the mails sent seem to arrive...

Regards

Warhead

PS I have found the content of the mails the forum was supposed to send in: 

/var/spool/postfix/maildrop

Does postfix write a log, where I could see, what goes wrong?

----------

## kashani

Couple things to try.

mailq

This command will should you anything in Postfix's queue and the short reason why its there. 

tail -n 500 /var/log/messages | less

Postfix is pretty good about logging why things went wrong. 

kashani

----------

## Warhead

mailq tells me the mail system is down...

/var/log/messages reveals:

postfix/postdrop[11734]: warning: unable to look up public/pickup: No such file or directory

Regards

Warhead

PS: After rebooting my system, the mailservice seems to work. I guess there were some conflicts (I merged and unmerged several MTAs today). But it seems my problem is beyond configuring, bacause when I send a mail to e.g. my googlemail account, it gets bounced:

The IP you're using to send email is not authorized  550-5.7.1 to send email directly to our servers. Please use  550 5.7.1 the SMTP relay at your service provider instead.

PPS: Tried to create another googlemail account for the forum, but I am unable to send via this one to:

Ran into problems sending Mail. Error: 530 5.7.0 Must issue a STARTTLS command first

----------

## kashani

And you *thought* you wanted a nice and simple MTA.  :Smile: 

There are a couple of solutions here and we're going to try the easiest one first. In your main.cf there is an example of how to set a relayhost. 

```

# The relayhost parameter specifies the default host to send mail to

# no relayhost is given, mail is routed directly to the destination.

#relayhost = $mydomain

#relayhost = [gateway.my.domain]

#relayhost = [mailserver.isp.tld]

```

So at the bottom or your config, I like having all my modifications at the bottom so I don't have to go looking through a large config for them, with the settings you added yesterday add this line. If you have comcast it's likely smtp.comcast.com and stuff like that.

```
relayhost = mailhost.yourisp.com 
```

I don't remember if the above needs to be in [] or if you can skip them so keep an eye on the logs after you add it and have restarted Postfix. However your ISP might require you to authenticate before you can send email which is a more complicated config. That should show up in the logs as well so post back with any of that info if it fails.

kashani

----------

