I have created a simple form to test my email capabilities from my new PHP 5.0 setup. I am very new to PHP, but have some experience with C.

So the question is, the script executes, but the mail is not being sent to the recipient, which is me of course for test purposes.

Can you advise on what I can do to resolve this dillema?πŸ˜•

Kevin

<?php
$sender_name= $POST[ 'sender_name'];
$sender_email=$
POST[ 'sender_email'];
$message=$POST[ 'message'];
$like_site=$
POST[ 'like_site'];

$msg = "Sender's Full Name: \t$sender_name\n";
$msg.= "Sender's E-Mail:\t$sender_email\n";
$msg.= "Did You Like the Site?\t$like_site\n";
$msg.= "Additional Message:\t$message\n\n";

$mailheaders = "From: My Web Site\n";
$mailheaders.= "Reply-To: $sender_email\n\n";

mail("example@example.com", "Feedback Form", $msg, $mailheaders);

echo "<H1 align=center>Thank You, $sender_name</H1>";
echo"<P align=\"center\">We appreciate your feed back.</P>";

?>

    Is display_errors set to On and error_reporting set to E_ALL ? Have you tried using a valid "From:" header ?

    If the "smtp" directive is set to localhost, are you sure you have an SMTP service running on the server (if you're testing this on your personal Windows computer, the answer is probably no)?

    Are you positive the e-mail isn't being intercepted and perceived as spam?

      Is display_errors set to On and error_reporting set to E_ALL ? Have you tried >using a valid "From:" header ?

      Looking at the phpInfo.php file that I created, I don't see
      display_errors
      I do see error_reporting set to 6143

      I have never worked with email before, my first attempπŸ†’

      When you say have I tried using a valid "from:" header? what are you
      refering to?

      If the "smtp" directive is set to localhost, are you sure you have an SMTP service >running on the server (if you're testing this on your personal Windows computer, >the answer is probably no)?

      I checked my services on my win2k under admin and SMTP is running.
      Are there any special configs that need to be added for PHP?

      Are you positive the e-mail isn't being intercepted and perceived as spam?
      I checked my garbage file where my spam is channeled to and nothing there!

        Kevin Raleigh wrote:

        Looking at the phpInfo.php file that I created, I don't see display_errors

        Really? If it's just the output of a simple phpinfo() call, it should be in the first table (PHP Core). The directives are listed alphabetically, so display_errors is approximately 9 rows above the one for error_reporting. If nothign else, you can always use [man]ini_get/man.

        Kevin Raleigh wrote:

        When you say have I tried using a valid "from:" header? what are you refering to?

        I mean a valid FROM header as defined in RFC 2822; valid examples can be found on the manual page [man]function.mail[/man] under the "to" parameter definition (the "From:" field should contain data similar to the "To:" header, so the examples the manual gives for the to parameter are applicable here).

          bradgrafelman wrote:

          Really? If it's just the output of a simple phpinfo() call

          I found the item, but for some reason when I change the value it is not recorded in the phpInfo.php file

          log_errors = On [Security]
          ; This directive complements the above one. Any errors that occur during the
          ; execution of your script will be logged (typically, to your server's error log,
          ; but can be configured in several ways). Along with setting display_errors to off,
          ; this setup gives you the ability to fully understand what may have gone wrong,
          ; without exposing any sensitive information to remote users.

          The above is the excert from the php.ini file and it clearly shows that the item has been engaged. I stopped and restarted my II services and even restarted the computer but still the item doesn't not show on the phpInfo.php file.
          What gives?

          I readup on mail from the link you provided. I grabed their example and tried posting that one with no results.
          <?php
          $to = 'example@example.com';
          $subject = 'email test';
          $message = 'email test';
          $headers = 'From: 'example@example.net' . "\r\n" .
          'Reply-To: example@example.net' . "\r\n" .
          'X-Mailer: PHP/' . phpversion();

          mail($to, $subject, $message, $headers);
          ?>

          Is there anything else that you can suggest?πŸ˜•

          Thank You
          Kevin

            (Quick note - I've removed the e-mail addresses from your posts; it's generally not a good idea to post your e-mail address in such a public place due to spam.)

            If you're making changes to the php.ini file and they aren't showing up, then you need to set the PHPRC environment variable (as described in this FAQ).

            At this point, I'm not sure what to diagnose - it could be that the local SMTP server isn't working properly, or that the e-mail is still being dropped by the remote mail server. I would suggest using network analyzers such as Ethereal/Wireshark to watch port 25 on your server and see if you can capture the SMTP traffic.

              bradgrafelman wrote:

              (Quick note - I've removed the e-mail addresses from your posts; .

              Thanx

              If you're making changes to the php.ini file and they aren't showing up,.

              problem solved

              At this point, I'm not sure what to diagnose - it could be that the local SMTP server isn't working properly, or that the e-mail is still being dropped by the remote mail server. I would suggest using network analyzers such as Ethereal/Wireshark to watch port 25 on your server and see if you can capture the SMTP traffic.

              Will look into etheral and see what gives. What does etheral do, grab the email before it is sent?

              I tried posting the email file to my websever. It didn't send an email to me either.
              The code is sound isn't it? By calling up the php page it should just send an email to me right? Looks like I have a bone to chew on:glare:

              I appreciate all your help
              Will post if I have any results

              Kevin

                A few comments in no particular order:

                You have an extraneous single quote on this line:

                $headers = 'From: [color=red]'[/color]example@example.net' . "\r\n" .
                

                To make sure you see all run-time errors, add this to the start of your script:

                ini_set('display_errors', 1);
                error_reporting(E_ALL);
                

                If mail() will not work for you, you might want to look into PHPMailer, which includes a SMTP class that will allow you to send email via any SMTP mail server on which you have an account (instead of using PHP's mail() command).

                  If mail() will not work for you, you might want to look into PHPMailer, which includes a SMTP class that will allow you to send email via any SMTP mail server on which you have an account (instead of using PHP's mail() command).

                  These are the instructions:
                  Installation:

                  Copy class.phpmailer.php into your php.ini include_path. If you are
                  using the SMTP mailer then place class.smtp.php in your path as well.

                  In the language directory you will find several files like
                  phpmailer.lang-en.php.

                  If you look right before the .php extension
                  that there are two letters. These represent the language type of the
                  translation file.

                  How do I include the class.phpmailer.php to include path?
                  Is this in the services module for win2k?
                  I hate to start hacking my include path without knowing what I should be doing
                  I found a few articles that showed unix but nothing on windows 2k
                  Kevin

                    The PHP include path is in your php.ini file. Normally, by default the current working directory is in the include path, so if those files are in the same directory as the script that will be including them, you'll probably be OK. If you want them elsewhere, you can either change the include_path setting in php.ini if possible and desirable, or set it locally via a .htaccess file command (if Apache webserver), or via ini_set() in the script itself.

                      I hate to sound dense, but I am really new to all of this. I just picked up a tutorial on PHP a couple of days ago. Now looking at my php.ini file I don't see anything that resembles include= anything.

                      So are you saying to use this path at the very top of the php.ini before the comments begin:

                      include_path = C:\Program Files\PHP\ext\class.phpmail.php
                      include_path = C:\Program Files\PHP\ext\class.smtp.php

                      where C:\Program Files\PHP\ is where my php resides?
                      and PHP\php.ini is where my .ini file resides?
                      Then copy and paste the files into the ext directory within php?

                      Kevin

                        You just want to specify the directory that contains your include file(s). So if you have them in C:\Program Files\PHP\ext\ directory, you would set the include path as:

                        include_path = ".;C:\Program Files\PHP\includes"
                        

                        Note that no trailing "\" is needed. Also note the ".;" at the start of the path, which is saying "look in the current working directory first". This latter "current directory" part is not necessarily needed at this time, but it's more or less a standard operating procedure, so you might as well put it in now.

                        PS: don't forget to restart your webserver after making any such configuration changes.

                          PS: If you don't want to mess with the php.ini file at this time, you can just add the following line to the start of your script to see if things are working:

                          <?php
                          ini_set('include_path', 'c:\\Program Files\\PHP\\ext');
                          // then include your phpMailer class:
                          require_once 'class.phpmailer.php';
                          
                            NogDog wrote:

                            PS: If you don't want to mess with the php.ini file at this time, you can just add the following line to the start of your script to see if things are working:

                            I was able to make the connection with the server. It returned my mail. My best guess is that I need to connect to the server using a logon with password and username. I don't think I did that with mail().

                            Thank You πŸ˜ƒ
                            Kevin

                              I have these errors when I included the class files per your instructions:

                              Warning: require(class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\phpBasics_5.0\hs~class_phpmailer.php on line 5

                              Fatal error: require() [function.require]: Failed opening required 'class.phpmailer.php' (include_path='.;C:\Program Files\PHP\phpmailer\class.smtp.php') in C:\Inetpub\wwwroot\phpBasics_5.0\hs~class_phpmailer.php on line 5
                              PHP Warning: require(class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\phpBasics_5.0\hs~class_phpmailer.php on line 5 PHP Fatal error: require() [function.require]: Failed opening required 'class.phpmailer.php' (include_path='.;C:\Program Files\PHP\phpmailer\class.smtp.php') in C:\Inetpub\wwwroot\phpBasics_5.0\hs~class_phpmailer.php on line 5

                              The first one I get; It states that it wants the class.phpmailer.php file in same directory as the file I am working on. What I don't get is why?

                              the files were included as you requested so it should work.
                              include_path = ".;C:\Program Files\PHP\phpmailer\class.phpmailer.php"
                              include_path = ".;C:\Program Files\PHP\phpmailer\class.smtp.php"

                              Located at the top of the file under the

                               tag
                              
                              insight would be appreciated
                              
                              Thank You
                              Kevin

                                Do not put the file name in the include path, just the directory where the files are:

                                include_path = ".;C:\Program Files\PHP\phpmailer"
                                
                                  Write a Reply...