my OS is Windows XP, i have installed apache server (2.0 X) .. i am writing a script to send an email via php mail function.

<?php
$to = "myAddress@hotmail.com";
echo "1";
$subject = "Hi!";
echo "2";
$body = "Hi,\n\nHow are you?";
echo "3";
if (mail($to, $subject, $body)) {
echo "4";
  echo("<p>Message successfully sent!</p>");
 } else {
 echo "6";
  echo("<p>Message delivery failed...</p>");
 }
?>

the mail doesn't send and i am getting the warning "Message delivery failed" .. i read few articles on this issue and got to know that you should configure the php.ini file enable the email feature, could some one send me the configuration code..

i am new to PHP .. plss help me :( :(

It appears in your script that there isn't a valid email. That is one thing that can cause an email delivery to fail. Also as for the php.ini file, it isn't that easy to configure. The php.ini file is driving me crazy to get my localhost php email function working. From what I have read, you need to configure the following lines of the php.ini file:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

And I think there are 2 ways to setup the delivery system. You can install/use a mail server that is on the same server as this php.ini file or you can use a remote mail server such as gmail to send the mail.

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = shaenator7@hotmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

this is how my code looks like, i even have a gmail account, so do u know how to do it using a remote server.. my ultimate goal is to send an email .. so please help me .. :) :)

All that I have manage to piece together is the following:

[mail function]
; For Win32 only.
SMTP = smpt.gmail.com
smtp_port = 465
;default 25

; For Win32 only.
;place below your gmail address
sendmail_from = username@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "\xampp\sendmail\sendmail.exe -t"
sendmail_path = "\xampp\sendmail\sendmail.exe"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

But even with the above gmail settings there must be something that needs adding because last time I tried authentication failed meaning it could not log into the gmail server. Perhaps somehow a password needs adding.

Then I'd consider switching to PHPMailer.

how do work with it, any sample code, i couldn't find it by browsing, but there is an extension called "mailparse"- email message manipulation ..

pop3 is also, there... do v have to configure these when it is available as extensions.
presently i have php version 5.2.6 .. 5.2.8 and 5.2.9 .. each version has different extensions,, i am fully confused, pllzz help me some 1

still no result .. i am still stuck . i think you should configure the php.ini file accordingly to send email,

i wander how others send email from php mail function.. if any1 knows please help me.. please please help ..

use phpmailer. you cannot set a password in the ini for mail(). that is the problem. you can set it with phpmailer. very easy to use.

use phpmailer. you cannot set a password in the ini for mail(). that is the problem. you can set it with phpmailer. very easy to use.

Yes, it appears that if you want to be able to use the mail function then you need to setup the computer running the script as a mail server. I wonder how you would over-come this on php-gtk?

This article has been dead for over six months. Start a new discussion instead.