PDA

Bekijk Volledige Versie : SMTP instellen op eigen Apache server



rvandergulik
12/01/11, 09:30
Hallo,

Ik heb nou al heeeeel wat uurtjes lopen stoeien met m'n mailscript op
www.AllBits-IT.nl/contact.html

Op een maatje zijn server werkt precies de zelfde script ook.. maar op mijn server doet hij alsof ie m verstuurt maar ik ontvang niks..

Nou uit eindelijk als ik een PHP mailscript gebruik krijg ik ook een foutmelding met dat ik m'n SMTP server moet instellen..

Dus neem aan dat ik wat op mijn server moet instellen.. maar waar? moet ik een port open zetten op m'n server?
Zou fijn zijn als iemand mij kan helpen. Alvast bedankt voor de moeite!

Mvg Richard

Triloxigen
12/01/11, 09:58
Als je het script niet plaatst dan kan niemand je helpen ben ik bang ;)

Magus
12/01/11, 10:36
Welke smaak linux? Redhat-smaken:

in iptables even poortje 25 naar buiten toestaan.

yum install sendmail
service start sendmail

done :)

rvandergulik
12/01/11, 12:12
Javascript:

<script src="email/lite_validation.js"></script>
<script>
required.add('Full_Name','NOT_EMPTY','Uw naam');
required.add('Email_Address','EMAIL','Uw e-mailadres');
required.add('Your_Message','NOT_EMPTY','Uw bericht')
</script>

Form:

<label for="Full_Name" class="required"><strong>Uw naam</strong><span class="Prijs"> * </span></label>
</td>
<td width="369" valign="top" class="cflite_td">
<input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:250px">
</td>
</tr>
<tr>
<td valign="top" class="cflite_td">
<label for="Email_Address" class="required"><strong>Uw e-mailadres</strong><span class="Prijs"> * </span></label>
</td>
<td valign="top" class="cflite_td">
<input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:250px">
</td>
</tr>
<tr>
<td valign="top" class="cflite_td">
<label for="Telephone_Number" class="not-required"><strong>Telefoon nummer</strong></label></td>
<td valign="top" class="cflite_td">
<input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:250px">
</td>
</tr>
<tr>
<td valign="top" class="cflite_td">
<label for="Your_Message" class="required"><strong>Uw bericht</strong><span class="Prijs"> * </span></label>
</td>
<td valign="top" class="cflite_td">
<textarea name="Your_Message" id="Your_Message" style="width:300px;height:120px"></textarea>
</td>
</tr>
<tr>
<td height="20" colspan="2" class="cflite_td" style="text-align:right"><br />
<input type="submit" value=" Verstuur E-mail ">

Lite_process.php:

<?php
// URL: www.freecontactform.com
// Version: FreeContactForm Lite V1.2
// Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail.com>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
if(isset($_POST['Email_Address'])) {

include 'lite_settings.php';

function died($error) {
echo "Sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

if(!isset($_POST['Full_Name']) ||
!isset($_POST['Email_Address']) ||
!isset($_POST['Telephone_Number']) ||
!isset($_POST['Your_Message'])) {

died('We are sorry, but there appears to be a problem with the form you submitted.');
}

$full_name = $_POST['Full_Name']; // required
$email_from = $_POST['Email_Address']; // required
$telephone = $_POST['Telephone_Number']; // not required
$comments = $_POST['Your_Message']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}

if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\r\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
$email_message .= "Email: ".clean_string($email_from)."\r\n";
$email_message .= "Telephone: ".clean_string($telephone)."\r\n";
$email_message .= "Message: ".clean_string($comments)."\r\n";

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>
<?
}
?>


lite_settings.php:

<?php

$email_to = "r.vandergulik@live.nl"; // your email address
$email_subject = "AllBits"; // email subject line
$thankyou = "../bedankt.html"; // thank you page

?>

lite_validation.js:

// URL: www.freecontactform.com
// Version: FreeContactForm Lite V1.1
// Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail.com>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){re turn false;}
return true;}
function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;}
return true;}
function $$(id){if(!has_id(id)&&!has_name(id)){alert("Field "+id+" does not exist!\n Form validation configuration error.");return false;}
if(has_id(id)){return document.getElementById(id).value;}else{return;}}
function $val(id){return document.getElementById(id);}
function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,'').replace(/\s+$/,'');}
var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Oeps! er is iets fout gegaan:\n\n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i<required.field.length;i++){if(this.checkit(require d.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+require d.field[i][2]+' moet worden ingevult\n';if(has_id(required.field[i][0])&&to_focus.length===0){to_focus=required.field[i][0];}
tmp=false;}}
if(!tmp){alert(error_message);}
if(to_focus.length>0){document.getElementById(to_focus).focus();}
return tmp;},checkit:function(cvalue,ctype,cform){if(ctyp e=="NOT_EMPTY"){if(this.trim($$(cvalue)).length<1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length>0){return s.replace(/^\s+/,'').replace(/\s+$/,'');}else{return s;}}};



Ik gebruik een Windows 7 Server met Apache. is het dan alleen een kwestie v an port 25 open zetten?

Gr. Richard

RackWerk
12/01/11, 12:22
Je zult e.e.a. op een windows machine moeten instellen in de php.ini.

Zie daarvoor: http://www.php.net/manual/en/mail.configuration.php#ini.smtp

Triloxigen
12/01/11, 12:31
@mail($email_to, $email_subject, $email_message, $headers);

Haal die @ eens weg, krijg je in ieder geval een foutmelding waar je op verder kunt borduren

dreamhost_nl
12/01/11, 12:59
Als je de mail()-functie in PHP gebruikt, gebruik dan wel de volledige functionaliteit. Er wordt in je code nergens afgevangen of er daadwerkelijk iets wordt afgeleverd:


$result = @mail($email_to, $email_subject, $email_message, $headers);
echo 'e-mail is',($result)?' ':' niet ','verstuurd';


Info : http://php.net/manual/en/function.mail.php

Ahmed
12/01/11, 13:21
Ik zou je aanraden phpmailer te gebruiken (link (http://phpmailer.worxware.com/index.php?pg=sf&p=dl)). Kun je ook direct de smtp goed instellen...