Jump to content

Archived

This topic is now archived and is closed to further replies.

tbailey

PHP mail() function

Recommended Posts

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

Share this post


Link to post
Share on other sites
Please post the code you're using. We can't help you without it.

Ken

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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! :-)

Share this post


Link to post
Share on other sites
The "From:" line should be terminated with a new-line character "\r\n"
[code]<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");
?>[/code]

Ken

Share this post


Link to post
Share on other sites
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() ?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.