Jump to content

PHP mail() function


tbailey

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
Link to comment
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?
Link to comment
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! :-)
Link to comment
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
Link to comment
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() ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.