Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ChrisA

macrumors G5
Jan 5, 2006
12,919
2,172
Redondo Beach, California
SIDETRACK POST -

Am I reading that website correctly? You can set up a DNS server, Mail server and Web server on any standard (non-Server) OS X Leopard system for just $15 each? And you're saying they work on OS X Server even better than the built-in OS X Server versions?

Why would you have to pay $15? Who would you pay it to?

All of that software (Bind, Postfix, Sendmail, Apache) is completely free and open source and will run equally well on Mac OS X, Linux, Solaris or any other Unix-like OS. You don't pay for or to use Open Source.

Yes Apple will charge you for "Server" but what you pay for is there configuration software and for Apple having to bundle up all that free software for you.

Possibly your ISP might charge you more if you run a server. Most do charge more for a "business" account that has no blocked ports and a static IP. So the connection my cost but the software is 100% free
 

awmazz

macrumors 65816
Jul 4, 2007
1,100
0
You don't pay for or to use Open Source.

You don't pay for it in time to learn it?

If someone packages day's or week's worth of learning and troubleshooting (as per the OP trying to get 'postfix' to work in this thread) into an easy to use GUI app that works to set everything up in minutes, $15 is not just an unequivocal bargain, it's a steal.
 

ChrisA

macrumors G5
Jan 5, 2006
12,919
2,172
Redondo Beach, California
You don't pay for it in time to learn it?

If someone packages day's or week's worth of learning and troubleshooting (as per the OP trying to get 'postfix' to work in this thread) into an easy to use GUI app that works to set everything up in minutes, $15 is not just an unequivocal bargain, it's a steal.

Yes and no. That's what Apple did with Mac OS X. A lot of Mac OS is open source and Apple makes it easy to use. So you are right

But on the other hand.. If the software is important to you and you depend on it. Then it is worth the effort to learn so as not to be dependent on something you don't understand and so you can trouble shoot.

Sendmail is a beast to configure. The O'Riley "bat book" must be 600 pages of very dense text and you need to know most of it to get Sendmail to work. Not reading that book is worth $15. Unless you need to do something complex and today if you are setting up your own mail server, unless it is a hobby, home server it is going to be complex.

Postfix is a lot easier to set up than Sendmail and that is it's biggest advantage
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
to those that it may concern:

in php, have you tried to do this:

mail($email, $subject, $mesg, $from);

this is how i send an email in php. it works on my server, even though i do not have a mail server running
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
need basic help

Hi,

I see that I need more basic help than I thought. I couldn't get the php to send mail out of my lan, so I decided to test it in my lan with this code:
<?php

$to = "rodrigo7x@localhost";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "rodrigo7x@localhost";
$headers = "From: $from";


mail($from,$to,$subject,$message,$headers);

if (mail($from,$to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>


the browser displays mail could not be sent. I would greatly appreciate if someone could help me diagnose this problem. If it helps, I am able to telnet localhost 25 and send myself emails from like that through the terminal. However, if I don't telnet and just do a mail command at the terminal I will get a:
usr/sbin/sendmail directory doesn't exist error.

and yes there is no such directory in that location of my Mac.

thanks for any advise.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
Hi,

I see that I need more basic help than I thought. I couldn't get the php to send mail out of my lan, so I decided to test it in my lan with this code:
<?php

$to = "rodrigo7x@localhost";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "rodrigo7x@localhost";
$headers = "From: $from";


mail($from,$to,$subject,$message,$headers);

if (mail($from,$to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>


the browser displays mail could not be sent. I would greatly appreciate if someone could help me diagnose this problem. If it helps, I am able to telnet localhost 25 and send myself emails from like that through the terminal. However, if I don't telnet and just do a mail command at the terminal I will get a:
usr/sbin/sendmail directory doesn't exist error.

and yes there is no such directory in that location of my Mac.

thanks for any advise.

please look at my above post, and try it the way i did it. like this:

mail($email, $subject, $mesg, $from);

and let us know if this works
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
my change

HI,

I change the php code to this:

<?php

$email = "rodrigo7x@localhost";
$subject = "Test mail";
$mesg = "Hello! This is a simple email message.";
$from = "rodrigo7x@localhost";


mail($email, $subject, $mesg, $from);

if (mail($email, $subject, $mesg, $from)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>


and received the mail could not be sent in browser. Thanks for helping.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
HI,

I change the php code to this:

<?php

$email = "rodrigo7x@localhost";
$subject = "Test mail";
$mesg = "Hello! This is a simple email message.";
$from = "rodrigo7x@localhost";


mail($email, $subject, $mesg, $from);

if (mail($email, $subject, $mesg, $from)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>


and received the mail could not be sent in browser. Thanks for helping.

try it with a real email address for $email and $from
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
Hi

I tried my gmail email for both the $email and the $from; I also tried my yahoo email; combination of both; and combination of localhost to both the gmail and yahoo and I still received "could not send mail" on my browser each time. Thanks.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
I tried my gmail email for both the $email and the $from; I also tried my yahoo email; combination of both; and combination of localhost to both the gmail and yahoo and I still received "could not send mail" on my browser each time. Thanks.

try the code like this:

Code:
if (mail($email, '$subject', $mesg, $from)) {
        return true;
      } else {
        throw new Exception('Could not send email.');
      }

and see if it works that way.
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
different error

HI,

I got this now:

Fatal error: Uncaught exception 'Exception' with message 'Could not send email.' in /Library/WebServer/Documents/rumortest.php:14 Stack trace: #0 {main} thrown in /Library/WebServer/Documents/rumortest.php on line 14
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
HI,

I got this now:

Fatal error: Uncaught exception 'Exception' with message 'Could not send email.' in /Library/WebServer/Documents/rumortest.php:14 Stack trace: #0 {main} thrown in /Library/WebServer/Documents/rumortest.php on line 14

hmm. well then it seems that php might not be installed correctly. what system do you have running?
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
I think so too

Yeah,

I thought a while ago that my postfix is not installed properly. I tried to put the postfix folder in the trash and then downloaded the 2.5 stable version but I got this at the end of the installation and it wouldn't install:

make: *** [master] Error 1
make: *** [update] Error 1


I have the postfix 2.4 version that came with my Mac os x 10.5. And I was going to double check the version I currently have but when I typed postfix mail_version I got this for some reason:

postfix/postfix-script: fatal: usage: postfix start (or stop, reload, abort, flush, check, set-permissions, upgrade-configuration)


I can stop, start and reload postfix just fine. Thanks.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
Yeah,

I thought a while ago that my postfix is not installed properly. I tried to put the postfix folder in the trash and then downloaded the 2.5 stable version but I got this at the end of the installation and it wouldn't install:

make: *** [master] Error 1
make: *** [update] Error 1


I have the postfix 2.4 version that came with my Mac os x 10.5. And I was going to double check the version I currently have but when I typed postfix mail_version I got this for some reason:

postfix/postfix-script: fatal: usage: postfix start (or stop, reload, abort, flush, check, set-permissions, upgrade-configuration)


I can stop, start and reload postfix just fine. Thanks.

hmm. i did not have to mess with postfix, though i am running mac os x server. i did reinstall php 5 though. i'm not real sure what to tell you.
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
halt

Hi,

Thanks so much for trying to help me. I went to mysql and found out it got misconfigured somehow when I was trying to uninstall postfix. Then I tried to install it again and got some errors. I might end up reinstalling the etc folder and usr folder from my installation disks or time machine. I will then post back if I figure out what happened, thanks.
 

twoodcc

macrumors P6
Feb 3, 2005
15,307
26
Right side of wrong
Hi,

Thanks so much for trying to help me. I went to mysql and found out it got misconfigured somehow when I was trying to uninstall postfix. Then I tried to install it again and got some errors. I might end up reinstalling the etc folder and usr folder from my installation disks or time machine. I will then post back if I figure out what happened, thanks.

good luck with it. sorry i couldn't be of more help. let us know what happens
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
mailserver for mac

Okay,

Hi eveyone, I took off a while and I wanted to pick up on this postfix mta on mac os x. I gave up trying to work with it, I bought the mailserver users recommended in this thread. However, nothing changed. But I think is because I don't know what to type in the mailserver gui.

Is there anyone with patience that could guide me as to what I need to fill in the mailserver gui to be able to get postfix to send email from my local environment. What I really want to do is to be able to send email from php but I guess just to get Mac's Mail application to work with the mailserver would be fine for now.

Thank you in advance.
 

rodrigo7x

macrumors newbie
Original poster
Dec 25, 2008
26
0
Php Mail sent with Postfix and phpmailer SOLVED!!!

Hi everyone,

I just want to post back specially to all of you who were real helpful in the process of getting this to work for me. I find it very complicated but it works now. Also before going on right now I feel that the mailserve for leapord is a rip off (probably cause I don't know how to use it) I bought it and ended up throwing it in the trash because I don't need it, it didn't even start postfix when I hit the postfix start icon. I still had to manually start postfix via terminal.

Anyhow, it's been a while and a long time since I started this thread so I don't know if I can cover every step to fix postfix to work with phpmailer as it was in my case on leopard. But here's my try.

this is the postfix main.cf configuration that worked for me:

confiugration that sends emails from Mac to Mac on Local envrionment or to outside emails.



# Minimum Postfix-specific configurations
mydomain_fallback = localhost
relayhost=smtp.gmail.com:587
mydomain=localhost
myhostname=localhost.com

# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

inet_interfaces = all
inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = localhost


#sendmail_path = /usr/bin/mail

smtp_enforce_tls = yes
smtp_sasl_tls_security_options =
smtp_sasl_tls_verified_security_options =
smtp_tls_loglevel = 2

# optional if you wan to see what's going on with the TLS negotiation in /var/log/mail.log
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_passwords
smtp_tls_per_site = hash:/etc/postfix/smtp_tls_sites
tls_random_source = dev:/dev/urandom


mail_owner = _postfix
setgid_group = _postdrop


On the php.ini changing the sendmail path to mail -t -i or leaving it as the default didn't make a difference for me.

I also followed this tutorial:

http://blog.yuweijun.co.cc/2008/11/send-mail-through-gmail-smtp-using-php.html

but this is how I modified it for my local environment:

<?php

require_once("/usr/local/php5/PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->ContentType = "text/plain"; // text/plain or text/html

$mail->Host = "localhost"; // had been hacked in class.smtp.php, ssl://smtp.gmail.com
$mail->SMTPAuth = false;
$mail->Username = "rodrigo7x@localhost.com";
$mail->Password = "xxxxx";

$mail->From = "rodrigo7x@gmail.com";
$mail->FromName = "www.gmail.com";
$mail->AddAddress("rodrigo7x@gmail.com");

// CC and BCC
// $mail->AddCC("test@test.com");
// $mail->AddBCC("anothermail@test.com");

$mail->Subject = "This is my subject";
$mail->Body = "This is my message";

if(!$mail->Send()) {
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Email sent";
}
?>


This site:
http://www.communitymx.com/content/article.cfm?page=2&cid=AF0CE

shows you how to modify the include path inside your php script incase you get this error I once got:


Warning: require_once(class.phpmailer.php) [function.require-once]: failed to open stream: No such file or directory in /Library/WebServer/Documents/mailer.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'class.phpmailer.php' (include_path='.:/usr/local/php5/lib/php') in /Library/WebServer/Documents/mailer.php on line 3


basically just put the path to the phpmailer class inside your php script!

Also, when you modify files like the postfix main.cf or php.ini make sure you do sudo postfix reload and sudo apachectl restart from the terminal for changes to take effect.

Also, I noticed that sometimes closing out the browser and reopening it fixes some things, I guess that's due to caching. I guess there's other ways to confiure postfix so that you can go directly to you isp for smtp but I found this that works. I had to read forums like this one to get my setup to work:

http://www.riverturn.com/blog/?p=239

cause you have to download a certificate to authenticate smtp. I remember I did a lot with that so you might have to google some more.

The other thing that I still don't understand is that although I can send emails now from php script and by telnet localhost 25 mail from: .. etc
I still cannot just type in terminal:

sh-3.2# date | mail -s test rodrigo7x@localhost.com
sh-3.2# mail: /usr/sbin/sendmail: No such file or directory


As you see somehow the machine thinks I want to use sendmail and according to some posts online postfix is suppose to have a link that executes any commands to sendmail towards postfix. But I guess it is not working for me. If any one has a fix for this, I appreciate it. Thank you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.