Jump to content


Photo

PHP mail() function


  • Please log in to reply
7 replies to this topic

#1 tbailey

tbailey
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 21 March 2006 - 09:15 PM

Hi,

I'm trying to use the php mail() function. I'm using PHP 4.3.10 on Win2K3 server. My SMTP is correctly pointing to my smtp server (a different box), however I'm getting nada when trying to send mail.

Please help :-)

Thanks soo much in advance.

t

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 March 2006 - 10:03 PM

Please post the code you're using. We can't help you without it.

Ken

#3 tbailey

tbailey
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 21 March 2006 - 10:12 PM

Have tried calling it from several files. I'm confident that the coding is not the problem, but rather something I'm missing in my system config.

Forgot to mention that the webserver is running IIS 6 also.

Do I need to set up a SMTP (local) virtual server in IIS?

#4 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 March 2006 - 10:14 PM

Mate throw us someting!

Post any error messages, the code for generating the email, its contenst adn headers and such forth....

We can't help until we can see what the problem is.

follow me on twitter @PHPsycho

#5 tbailey

tbailey
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 21 March 2006 - 10:20 PM

k.

Here's a sample form:
<form action="tbaileyprocess.php" method="post">
Name: <input type="text" name="name" size="20" maxlength="20" /><br />
Email: <input type="text" name="email" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30" /><br />
Text:<textarea name="text" name="text" cols="50" rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>
---------------------------------------
the FILE: tbaileyprocess.php:
---------------------------------------
<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
mail('myemail@myemail.com',$subject,$text,"From: $name <$email>");
header("location:tbaileyform.php");
?>

Like I said, I'm sure that this coding is fine. But am thinking that I'm missing something in my system. Nagging in the back of my mind is how does my smtp server authenticate this mail being sent? All I have pointing to the server is the SMTP setting in php.ini

???

Thanks! :-)

#6 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 March 2006 - 10:28 PM

The "From:" line should be terminated with a new-line character "\r\n"
<php
<?php
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$subject = stripslashes($_POST['subject']);
$text = stripslashes($_POST['text']);
$to = 'myemail@myemail.com';
$headers = "From: $name <$email>\r\n";
mail($to,$subject,$text,$headers);
header("location:tbaileyform.php");
?>

Ken

#7 tbailey

tbailey
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 21 March 2006 - 10:35 PM

Like I said.... I'm dubious placing the code on the site....

I've tried several files (some of which have been tested on other systems and work perfectly). Please....the coding IS NOT the problem. The issue is somewhere in my flow / configuration.

Is there something that should be specified in IIS that would effect this?

On the SMTP server that the mail function sends to, is there some parameters that need to be set to accept the email that originates from mail() ?



#8 tbailey

tbailey
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 21 March 2006 - 11:41 PM

Please, can anyone help with this?

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users