# Where is the .mc or sendmail.mc file



## mroussin51 (Sep 15, 2012)

Hello,

I am not able to find an .mc file that resembles that of sendmail.cf. I would not expect to craft one from scratch. I would appreciate some insight.

Thanks in advance!

Mike


----------



## wblock@ (Sep 15, 2012)

The system will make one.  Make sure a valid hostname(1) has been set, then
`# cd /etc/mail && make`

_hostname_.mc will be created.


----------



## mroussin51 (Sep 15, 2012)

*Thanks one more question if I may*

Does hostname.cf replace sendmail.cf?


----------



## mroussin51 (Sep 15, 2012)

*Solved*

I just compared and it appears to be so. Now if I could just get somebody to configure it for me lol. 

Thanks for clearing that up!


----------



## wblock@ (Sep 15, 2012)

The comments at the start of /etc/mail/Makefile show all the things that it automates.  This is an excellent bit of automation that is underappreciated.


----------



## mroussin51 (Sep 16, 2012)

*I appreciate it!*

I am still green as evidence would show but I certainly appreciate the incredible amount of time that has been committed to the development and support of FreeBSD. 

I hope others appreciate it too!

Mike


----------



## proton1234 (Dec 12, 2019)

wblock@ said:


> The system will make one. Make sure a valid hostname(1) has been set, then


could you explain please the correct name is mydomain.com or mydomain.com. (ending with dot)


----------



## proton1234 (Dec 12, 2019)

I'm trying to use this guide https://www.bonusbits.com/wiki/HowTo:Configure_SendMail_to_Use_SMTP_Relay

But seems sendmail even don't try to connect to my smtp.myprovider.com

sendmail -v user@mailbox.com says
Connecting to [127.0.0.1] via relay...


----------



## SirDice (Dec 12, 2019)

Your mail(1) command still connects to the local MTA (sendmail), it's that MTA that will move the  mail to the configured smart host (your smtp.myprovider.com).


----------



## proton1234 (Dec 12, 2019)

SirDice said:


> Your mail(1) command still connects to the local MTA (sendmail)


Why "mail" command if I invoke "sendmail"?


SirDice said:


> it's that MTA that will move the mail to the configured smart host (your smtp.myprovider.com).


As I can see from -v output sendmail is still trying to send mail from currentOSuser@mydomain.com instead of configured account at smtp.myprovider.com

Seems like I need to perform some additional steps from here https://www.freebsd.org/doc/handbook/SMTP-Auth.html because there is no saslauthd installed on my system.


----------



## SirDice (Dec 12, 2019)

Did you run `make` and `make install` in /etc/mail/? Then `make restart` to restart sendmail(8) to have it pick up the new config? 

For a local submit you need to modify /etc/mail/`hostname -f`.submit.mc (or the *.cf if you're hardcore). I often mix them up and edit the wrong files.

For testing I just send an email using the mail(1) command, then watch /var/log/maillog.



proton1234 said:


> As I can see from -V output sendmail is still trying to send mail from currentOSuser@mydomain.com instead of configured account at smtp.myprovider.com


That will always happen, if you need to change it you're going to need to do more configuration. This is not done by setting a smart host. A smart host is just the next step in a chain of mailservers where mail gets transferred to. It doesn't change anything of the originally submitted email (which will have a source address of $user@$hostname). To change that $hostname part to $mydomain you need to set DOMAIN_NAME in the mc file, or Dj in cf.


----------



## proton1234 (Dec 12, 2019)

SirDice said:


> Did you run  make and  make install in /etc/mail/? Then  make restart to restart sendmail(8) to have it pick up the new config


only make as was said in the guide then service sendmail restart


----------



## proton1234 (Dec 12, 2019)

SirDice said:


> This is not done by setting a smart host.


have you looked here? https://www.bonusbits.com/wiki/HowTo:Configure_SendMail_to_Use_SMTP_Relay I assume that I defined a smarthost.


----------



## SirDice (Dec 12, 2019)

Yes, I did look at that. That's why I mentioned it. Normally the MTA (in this case sendmail(8)) will try to lookup the MX record of the destination domain and deliver the mail on its own. When you define a smart host _all_ mail is transferred to the smart host and it's assumed the smart host takes care of further delivery. Setting a smart host doesn't change anything on the originally submitted email, it's passed on 'as-is'.

In this respect a smart host is similar to setting a gateway for TCP/IP. It just passes the packets to the gateway and the router passes it further along. It doesn't change anything on the original packet, it's just a way to route traffic.


----------



## proton1234 (Dec 12, 2019)

SirDice said:


> When you define a smart host _all_ mail is transferred to the smart host and it's assumed the smart host takes care of further delivery.


As far as I understand if remote smtp server requires login and password my config won't work without saslauthd running
By the way my rc.conf setings are

```
sendmail_enable="NO"
sendmail_outbound_enable="NO"
sendmail_submit_enable="YES"
sendmail_msp_queue_enable="YES"
```


----------



## SirDice (Dec 12, 2019)

proton1234 said:


> As far as I understand if remote smtp server requires login and password my config won't work without saslauthd running


That's possible, normally an MTA just delivers the email on port 25, no authentication, nothing, just connect and deliver. That's one of the reasons why spamming is so easy to do. 

You can remove all those `sendmail_*` options, it's the default way sendmail(8) starts (see /etc/defaults/rc.conf).


----------



## proton1234 (Dec 12, 2019)

SirDice said:


> You can remove all those `sendmail_*` options, it's the default way sendmail(8) starts (see /etc/defaults/rc.conf).


I need sending only sendmail or other MTA with delivery mode = "background" with message queue to send messages from website via PHP mail so I don't think that it's a good idea to rollback to defaults. Correct me if I'm wrong please.


----------



## SirDice (Dec 13, 2019)

proton1234 said:


> to send messages from website via PHP mail so I don't think that it's a good idea to rollback to defaults.


Are you stuck with PHP mail? Or can you use other libraries? In your case mail/phpmailer might be a better and easier solution. It can connect directly to your mail provider (with authentication). That way you don't have to configure a local MTA.


----------



## proton1234 (Dec 15, 2019)

SirDice said:


> Are you stuck with PHP mail? Or can you use other libraries? In your case mail/phpmailer might be a better and easier solution. It can connect directly to your mail provider (with authentication). That way you don't have to configure a local MTA.


PHP+ smtp authentification will work in interactive mode too. Connecting to smtp provider in interactive mode is slow - one message to send would take ~5 sec and system would be busy until it get an Ok or an Error from smtp server. While in background delivery mode system is available immediately. You can test it by yourself changing in submit.cf delivery mode from `i` to `b` and then send to someone something via sendmail yourbuddy@hismailbox.com[/COLOR]

```
# default delivery mode
O DeliveryMode=i
```
ssmtp is a good alternative to sendmail in my case but it work only in interactive mode, msmtp seems do the same and interactive only too.


----------

