diverting all emails to an smtp server with sendmail

Hi,
Getting slowly up to speed with Apache22, MySQL, PHP5 on FreeBSD 9. The uname -a output is...

Code:
uname -a
FreeBSD paranoia.ourplace.org 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012     [email]root@amd64-builder.daemonology.net[/email]:/usr/obj/usr/src/sys/GENERIC  amd64"

Now I wish to use email on php, but need the MTA (preferably sendmail) to forward emails to an smtp server server account. Where I can send web users emails.

Is there anyway to change sendmail's configuration to do just that?

Thanking you in advance,
Jono.
 
If you just want the local sendmail to forward all emails to another SMTP server do the following. Go into the /etc/mail directory and run make. This will create a file called {hostname}.mc. Edit this file and uncomment the smart host line, changing the server address to be your SMTP server. Then run make install restart. I'm not sure about the settings if your SMTP server requires authentication though - I have the IP addresses of all my web servers as allowed relays on our SMTP servers.

Note that the local hostname will need to be resolvable in DNS otherwise you'll just get 'data format' errors on the SMTP server.

If you are writing your own PHP code, I would highly recommend using a proper mail library like Swiftmailer. Not only does it provide a nice interface for constructing the email, recipient/sender details etc, but will make it very easy if you ever want to add attachments or html/inline content and supports sending direct to an external SMTP server without needing any local mail support.
 
I'm going to proceed with the 2nd method i.e. mail/ssmtp and see how I go. If anybody wants to address using sendmail to do what I wanted please do so. I would be interested.

Peace,
Jono.
 
It's a matter of time, I found it heaps easier to configure mail/ssmtp. Now I'm having problems with interfacing php & apache with it....... doh!

But working away on that one.

Cheers,
Jono.
 
Johnny2Bad said:
It's a matter of time, I found it heaps easier to configure mail/ssmtp. Now I'm having problems with interfacing php & apache with it....... doh!

  1. Set sendmail_path = in /usr/local/etc/php.ini to /usr/local/sbin/ssmtp -t (s. http://php.net/sendmail-path)
    .
  2. Make a copy of /usr/local/etc/ssmtp/ssmtp.conf.sample to /usr/local/etc/ssmtp/ssmtp.conf and change
    therein the obvious parameters to your need.
    .
  3. Start using the following php-function in your php code (s. http://www.php.net/manual/en/function.mail.php).
    Code:
    bool mail(string $to, string $subject, string $message[, string $additional_headers[, string $additional_parameters]])

Think of configuring your favorite mail client for SMTP out. The above is meant to do exactly the same.

Best regards

Rolf
 
Yeah all is good now, I have it going. The mistake I made was.
1. Set sendmail_path = in /usr/local/etc/php.ini to /usr/local/sbin/ssmtp -t (s. http://php.net/sendmail-path)
.
I had the silly thing pointed to /usr/sbin/ssmtp rather than /usr/local/sbin/ssmtp. Thus the error.

When I do have time I will re-address this issue, unless someone else wants to take up the "sendmail" diverting ball. But I am in such a rush at the moment that I would like to concentrate on getting this webpage going.

Isn't there always something else to do with an installation of FreeBSD :P

Thankyou again,
Jono.
 
Back
Top