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

Spinal

macrumors newbie
Original poster
Mar 7, 2007
3
0
Howdy! First post on this thread, I've been "forwarded" to this forum from another forum I frequent (mbclub) - and am having a few issues setting up sendmail on a OsX box. First and foremost, let me be blunt - I've never set up sendmail before, and am really stumbling in the dark. All I need is a way to send messages to a couple of members of the IT team whenever a user posts a request for help or equipment.

I've enabled PHP and mysql on one of the boxes I'm administering. The box runs as an internal-website (i.e. DNS entry on our internal DNS server, but no ip/port forwarding specifically to the box so the outside world can't "see" the box).

The box runs OsX (10.4.8); apache (some version) (neither installed by me) - and now Apache's php and mysql add-ons. I configured php and mysql this afternoon, and both are working quite happily. php I did as such (in httpd.conf)

Uncommented:
Code:
LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c

Added:
Code:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.htm
</IfModule>

Now, I typed up a quick html page; something on the lines of:
Code:
<form method="get" action="sendmail.php"><br />
Email: < input name="email" type="text" /><br/>
Message:<textarea name="message" rows="10" cols="30"></textarea><br />
<input type="submit" /></form>
and a quick php script:
Code:
<?$email = $_GET['email'] ;
$message = $_GET['message'] ;

mail( "***@***-england.co.uk", "Email Subject", $message, "From: $email" );
print "Mail Sent";
?>
(the *** replace my email at work)

Now, if I give the whole thing a blast, it happily replies with "Mail Sent" - which is good... php hasn't crashed, no errors, bla bla...

BUT... nothing ever comes through on the mail client side... I've tried alternative email addresses... nada... My first idea was that as the box is behind a proxy, the proxy might be filtering everything out (the proxy is set up in such a way that EVERYTHING needs to go through a specific IP:pORT to get to the outside world)... But the box is configured to go through that proxy (and can connect to the net). Does apache or *nix's sendmail have their own proxy configs?

My second thought went down the lines of the ISP wanting us to use their SMTP server, double checked - thats not the case. We have a leased line and simply put, have almost no restrictions other than bandwidth...

If not, any ideas? I'm at a total loss...

Thanks in advance,
Michele

p.s. sorry about the typos, its been a long day and I'm quite far from a cup of coffee...
 
I'm not quite sure about server issues, but you might try using a POST form action and sending the correct header information and formatting the message...

PHP:
<?php
$email = $_POST['email'] ;
$message = wordwrap($_POST['message'], 76, "\n");

$headers	 = "MIME-Version: 1.0\n";
$headers	.= "From: $name <$email>\n";
$headers	.= "Content-Type: text/plain; charset=\"utf-8\"\n";

mail( "***@***-england.co.uk", "Email Subject", $message, $headers);
?>

These are merely best practices, as far as I know...
 
Thanks for the reply. I used GET because I can edit the data in the URL and fiddle with it alot faster, I'll change it to post once it works... That can't be killing the script (php gets the data, I checked).

Now, I've done some changes:
Code:
      <?
      $toEmail = $_GET['toEmail'] ; // variable declarations and initialisations from GET
	  $fromEmail = $_GET['fromEmail'];
      $message = $_GET['message'] ;
	  $subj = $_GET['subject'];
	  
	  $headers     = "MIME-Version: 1.0\n";
	  $headers    .= "From: $fromEmail <$fromEmail>\n";
	  $headers    .= "Content-Type: text/plain; charset=\"utf-8\"\n";

      mail( $toEmail, $subj, $message, $headers );
      print "Congratulations your email has been sent to $toEmail from $fromEmail <br /> Re: $subj <br>$message";
	?>

I realise the subject isn't sent... but don't really care! I'm starting to think that sendmail needs to be configured to see "through" our proxy, but I can't find a coherent manual on sendmail... Might pass by the bookstore later!

Michele
(still doesn't work...)
 
This is the script I have been using on numerous web site and various servers with success. Proxy should'nt be a problem since the script is interpreted by the server wich provide the parameters for the mail command.

$to = "name@domain.com";
$sujet = "subject line";

//--- la structure du mail ----//

$from = "From:$email\n";
$from .= "MIME-version: 1.0\n";
$from .= "Content-type: text/html; charset= iso-8859-1\n";

//--- un exemple de message avec corps en html ---//
$message="<table width=500><tr><td>Name: $name</td></tr><tr><td>Email: $email</td></tr><tr><td>The message: $text</td></tr></table>";

//--- on envoie l'email ---//
mail($to,$sujet,$message,$from);

echo "<div align=center>Thanks ! $name<br><br>Your email have been sended</div>";
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.