Please help me with sendmail!

9 replies
Hi all

I hope you can help me. I set up a simple form on my website, only fields for name and e-mail and a send button. I am using Joomla, and I added the folowing code in the source field of an article. (Should it be here or somewhere else?)

<form action="sendmail.php" method="post" name="Form">
<p style="text-align: center">Name&nbsp;&nbsp;&nbsp; <input name="Name" type="text" /></p>
<p style="text-align: center">E-mail&nbsp;&nbsp; <input name="E-mail" type="text" /></p>
<p style="text-align: center"><input type="submit" name="Send" value="Send" /></p>
</form>
<?php
$Name = $_REQUEST['Name'] ;
$E-mail = $_REQUEST['E-mail'] ;
mail( "me@mysite.com", "Feedback Form Results",
$message, "From: $Name" );
header( "Location: http://www.redirecthere.com" );
?>


I made sure sendmail is selected in the global configuration, and the sendmail path is given as /usr/sbin/sendmail.

Now when I enter values and click send on my site I get the following message: "The page cannot be found". The URL of this page is http://www.mysite.com/sendmail.php. What is wrong? I know this is a simple form, but I want to test the sendmail function before I write a more complicated form script.

Thanks
#sendmail
  • Profile picture of the author Aronya
    Does the sendmail.php file actually exist in the root folder of your site?
    Any differences in capitalization between the file name & the reference to it in your code?
    If you manually type in the address to the file in a browser, what do you get?

    The sendmail.php file has to exist where your form is looking for it. In this case, since you aren't specifying the full URL (http:\\www...sendmail.php), the server is going to be looking for it in the same directory as the page your form is on. If it's in another location, either move it, or fix the location in the form: <form action="sendmail.php"...>
    {{ DiscussionBoard.errors[1037809].message }}
  • Profile picture of the author MemberWing
    $E-mail - invalid variable name.
    Make it $e_mail


    Gleb
    {{ DiscussionBoard.errors[1038547].message }}
    • Profile picture of the author Cruiser
      Okay I'll give it a try.

      I just want to make sure (I am a day into coding...okay). I am using Joomla, and in the editor for articles there is a button to see the code, must I put both the HTML and PHP code there? In the global configuration Joomla gives the path of sendmail as I said above...should I change it somehow to the path of the article?

      Thanks for your time!
      {{ DiscussionBoard.errors[1039327].message }}
      • Profile picture of the author Cruiser
        It still don't work. I corrected the variables in the code. In the global configuration of Joomla the path of sendmail is given as /usr/sbin/sendmail (just like that - it is the default path - I didn't change anything).

        What I noticed is, when I save the article and open it again, the name of the form is changed to [object] when you click on form properties in the editor. However it still remains form in the code. I changed the name of the form to [object] in the code, and it still doesn't work.

        When I submit a name and e-mail I get a error that the page cannot be displayed. The URL of this page is www.mysite.com/sendmail.php!

        Please help! I am so frustrated, I am struggeling for a week now!
        {{ DiscussionBoard.errors[1039362].message }}
        • Profile picture of the author Cruiser
          Okay I think I know what is wrong. I saw that I must upload a file called sendmail.php somewhere via my ftp directory. Can someone please send me a link to such code and where I must put it?
          {{ DiscussionBoard.errors[1039718].message }}
          • Profile picture of the author Aronya
            Originally Posted by Cruiser View Post

            Okay I think I know what is wrong. I saw that I must upload a file called sendmail.php somewhere via my ftp directory. Can someone please send me a link to such code and where I must put it?
            Okay. What part of my post did you not understand?
            {{ DiscussionBoard.errors[1040309].message }}
            • Profile picture of the author Cruiser
              Sorry...I am new to all this stuff! I think I did everything right now. When I click on send I get the following message:

              Warning: Cannot modify header information - headers already sent by (output started at /home/voxvoxis/public_html/sendmail.php:2) in /home/voxvoxis/public_html/sendmail.php on line 8
              {{ DiscussionBoard.errors[1042110].message }}
            • Profile picture of the author Cruiser
              Just another thing, when I build the form in Joomla, I name the form as "form". Then when I add the text boxes an the button, the form name automatically change to [object]. I have tried to rename it back to form but it doesn't accept this change. Why is this happening?
              {{ DiscussionBoard.errors[1042112].message }}
  • Profile picture of the author Cruiser
    It works!!!
    Thanks everyone!!
    {{ DiscussionBoard.errors[1042122].message }}

Trending Topics