I have some forms that i have used to send to my e-mail using the php mail() function. I have had som issues with it because the mailservice i am using is not on the same server as the domain, so now i am forced to change the way i send e-mails(if i dont want to set ut an intirely new mail on that server).

Someone gave me a tip about the smpt authentication and pear mail, after reading about it i decided that this i something i can use. I have searched for post about setting up souch a form but i can't find anyting that describes my problem. I have a problem with structuring the script and now i am in a bit of a time crounch. This is the code that i use now with the mail() function.

<form action="" method="POST" class='kredittkortform'>
<table class='kreditttable'>
<td colspan="2"><b>Personopplysninger:</b></td>
   <td><input type='text' name='personnummer' value="<?php echo      isset($_POST["personnummer"])? $_POST["personnummer"] : ''; ?>" /></td>

 <td>Fullt navn:</td>
   <td><input type='text' name='navn' value="<?php echo isset($_POST["navn"])?  $_POST["navn"] : ''; ?>"  /></td>
<td><input type='submit' name='submit' value='Send søknad' style='height: 25px; width: 110px;margin-left:60px;' /></td>


  $besked = "<b>Personopplysninger:</b> <br />";
  $besked .= "Personnummer: ". $_POST["personnummer"]."<br />";
  $besked .= "Navn: ". $_POST["navn"]."<br />";
  $to2 = "mymail@myadress.com";
  $to = "myothermail@myadress.com";
  $subject = "Hei";
  $message = "Navn: " . isset($_SESSION["navn"]) . "<br />";
  $message .= "Email: " . isset($_SESSION["epost"]) . "<br /><br />";
  $message .= $besked;
  $headers = 'MIME-Version: 1.0' . "\r\n"; 
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  $headers .= "Fra:".isset($_SESSION["epost"]);
  $headers .= "\nReply-To:". isset($_SESSION["epost"]);
  $sentOk = mail($to,$subject,$message,$headers);
  $sentOk2 = mail($to2,$subject,$message,$headers);
  mysql_connect('***', '***', '***') or die(mysql_error());;
  //echo "Connected to MySQL<br />";
  mysql_select_db('***') or die(mysql_error());;
  //echo "Connected to Database";
  $email = isset($_SESSION["epost"]);
  mysql_query("INSERT INTO email (email, kilde) VALUES ('$email', 'Hei')");
  echo "<span style='color:red;font-size:30px;'>Takk for din søknad. Du vil bli kontaktet  innen kort tid.</span>";

I have managed to make a simple form that sends the mail right when i open the page, but i need it to send the mail when te submit button is pushed. And i have not found out where and how to place the information regarding the mySQL server. Can anyone help me with this? It would be much appriciated!

Thanks in advance.

Maybe you server config have something mistake.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.