Jump to content

Problem with mail form...


nysmenu

Recommended Posts

Hi, I was wondering if someone can help me please. I have this form set up called "contact" and the sending script is sending e-mails into my inbox but, it's not posting any information. Would someone please advice on what I'm doing wrong? Thanks.

 

Here's the form:

<form id="form1" name="form1" method="post" action="testing.php">
      <table width="552" border="0" align="left">
        <tr>
          <th width="110" align="left" scope="col">Name:</th>
          <th width="432" align="left" scope="col"><label for="name"></label>
            <label for="name4"></label>
            <input name="name" type="text" class="name1" id="name4" />
            <label for="name2"></label></th>
        </tr>
        <tr>
          <th align="left" scope="col">Last name:</th>
          <th align="left" scope="col"><label for="lname"></label>
          <input name="lname" type="text" class="lname" id="lname" /></th>
        </tr>
        <tr>
          <th align="left" scope="col">E-mail:</th>
          <th align="left" scope="col"><label for="email"></label>
          <input name="email" type="text" class="email" id="email" /></th>
        </tr>
        <tr>
          <th align="left" scope="col">School:</th>
          <th align="left" scope="col"><label for="school"></label>
          <input name="school" type="text" class="school" id="school" /></th>
        </tr>
        <tr>
          <th align="left" scope="col">Message:</th>
          <th align="left" scope="col"><label for="message"></label>
          <textarea name="message" cols="45" rows="5" class="message" id="message"></textarea></th>
        </tr>
        <tr>
          <th align="left" scope="col">Insert code ></th>
          <th align="left" scope="col"><table width="414" border="0" cellspacing="5">
            <tr>
              <th width="52" align="left" scope="col"><img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" /> </th>
              <th width="117" align="left" valign="bottom" scope="col"><input name="captcha_code" type="text" class="captcha" size="15" maxlength="6" /> </th>
              <th width="219" align="left" scope="col"><a href="#" onclick="document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random(); return false">Reload Image</a> </th>
            </tr>
          </table></th>
        </tr>
        <tr>
          <th align="left" scope="col"> </th>
          <th align="left" scope="col"><label for="submit"></label>
          <input type="submit" name="submit" id="submit" value="Submit" /></th>
        </tr>
      </table>
    </form>

 

and here's the sendingscript:

 

<?php
// Where to redirect after form is processed.
$url = 'http://www.car4students.com/contact.php';

require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->CharSet ="utf-8"; // You can adjust the Charset according to your language
$mail->IsSMTP();
$mail->Host = "mail.car4students.com";
$mail->From="[email protected]"; //REMEMBER, this MUST be same as your authorization email address above.
$mail->FromName="Contact Page";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "pass";

$mail->AddAddress("[email protected]");
$mail->name="louie";
$mail->subject = "Test 1";
$mail->body = "Test 1 of PHPMailer.";



if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "E-mail sent";
   echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}?>

 

Notice, I removed the captcha feature from the sending script as it is not a part of the script. Thanks

Link to comment
https://forums.phpfreaks.com/topic/170648-problem-with-mail-form/
Share on other sites

Couldn't you try something really simple like

$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}

 

Don't forget that some servers won't see that variables as $email when posted via a form

try either using $_POST['email'] or

 

$email = $_POST['email']; //Then you can use the $email variable.

 

Hope this helps.

 

Thanks L. I tried it and this is what I get:

 

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\hosting\member\car4students\c4site\test.php on line 27

 

Message delivery failed...

Error sending: You must provide at least one mailer is not supported.

Hi L or anyone else, I spoke to my server. (not much help) However, they said I needed to integrate the script to work with the contact page. My problem is that I'm fairly new to this and there are some things I just don't understand still. This is the first time using a server that requires SMTP auth. Would you be so kind and point me in the right direction? I have been fighting with this thing for 2 days already. Thank you.

 

this is what I did:

 

<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $message, $email)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->CharSet ="utf-8"; // You can adjust the Charset according to your language
$mail->IsSMTP();
$mail->Host = "mail.car4students.com";
$mail->From="[email protected]"; //REMEMBER, this MUST be same as your authorization email address above.
$mail->FromName="My site's mailer";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "pass";
?>

And this is what I keep getting:

 

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\hosting\member\car4students\c4site\testing.php on line 12

 

Message delivery failed...

 

Hi yes wamp is an option. Clearly your not running that.

To be honest if you host is not being too helpful ask their support

guys to give you some documentation on the subject.

 

You can check your

php ini file really easily. Google php.ini and choose the entry from php.net.  Shows you how to do it there

 

only one line.

Archived

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

×
×
  • 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.