|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi there,
i uploaded my site to a linuxwebserver (at www.hostbasket.com). there's a php mailscript in this site. i was running phperl on my pc and there everything worked just fine, but it doesn't work on the linuxserver. here's the script (the code that evaluates the fields works fine, i checked that, the problem is in the mailing itself - i think) <?php $count = 0; $meel = 0; $probleem = "<head> <title>Immac & Partners - NIEUWSBRIEF</title> </head><body topmargin=3 leftmargin=3><img src='../images/logo.gif'><hr size=1> <font face=verdana size=1 color=red><b>Uw bericht is niet verzonden!<br />Mogelijk is er een probleem met uw mailserver.<br />Gelieve later opnieuw te proberen.</b><br /><br />"; $verzonden = "<head> <title>Immac & Partners - NIEUWSBRIEF</title> </head><body topmargin=3 leftmargin=3><img src='../images/logo.gif'><hr size=1> <font face=verdana size=1 color=black><b>Uw bericht is verzonden!</b><br /><br />"; $leeg = "<head> <title>Immac & Partners - NIEUWSBRIEF</title> </head><body topmargin=3 leftmargin=3><img src='../images/logo.gif'><hr size=1> <font face=verdana size=1 color=red><b>!! Volgende velden werden niet of foutief ingevuld</b><br /><br />"; if(empty($name)) { $count = $count + 1; $leeg .= " Naam - niet ingevuld<br>"; } if(empty($fname)) { $count = $count + 1; $leeg .= " Voornaam - niet ingevuld<br>"; } if(empty($onderwerp)) { $count = $count + 1; $leeg .= " Onderwerp - niet ingevuld<br>"; } if(empty($vraag)) { $count = $count + 1; $leeg .= " Vraag - niet ingevuld<br>"; } if(empty($functie)) { $count = $count + 1; $leeg .= " Functie - niet ingevuld<br>"; } if(empty($company)) { $count = $count + 1; $leeg .= " Naam bedrijf - niet ingevuld<br>"; } if(empty($adres1) || empty($adres2)) { $count = $count + 1; $leeg .= " Adres - niet ingevuld<br>"; } if(empty($from)) { $count = $count + 1; $leeg .= " Email - niet ingevuld<br>"; $meel = 1; } if(empty($tel)) { $count = $count + 1; $leeg .= " Tel - niet ingevuld<br>"; } function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("[^@]{1,64}@[^@]{1,255}", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } if (!check_email_address($from)) { if ($meel == 0) { $count .= 1; $leeg .= " Email - foutief ingevuld<br /><br />"; } } if (!empty($attachment)) { if ($attachment_type) $mimeType = $attachment_type; else $mimeType = "application/unknown"; $fileName = $attachment_name; $fp = fopen($attachment, "r"); $read = fread($fp, filesize($attachment)); $read = base64_encode($read); $read = chunk_split($read); $filename = $_FILES['attachment']['name']; $stringarr = explode(".", $filename); $extension = $stringarr[count($stringarr)-1]; if ($extension != "txt") { if ($extension != "doc") { if ($extension != "xls") { if ($extension != "pdf") { $leeg .= " Bestand - verkeerd bestandstype (toegelaten : doc, xls, txt en pdf)<br />"; $count .= 1; } } } } $sfile = $_FILES['attachment']['size']; if ($sfile > 500000) { $leeg .= " Bestand - bestandsgrootte overschreden (max. 0.5 MB)<br />"; $count .= 1; } } $leeg .= "</font>"; if ($send) { if ($count == 0) { $boundary = uniqid( ""); $headers = "From: $from Content-type: multipart/mixed; boundary=\"$boundary\""; $body = "<font face=verdana size=2><u><b>VRAAG VAN WEBSITEBEZOEKER</b></u></font><br><br><font face=verdana size=1><b>Naam</b> : ".$name."<br /><b>Voornaam</b> : ".$fname."<br /><b>Functie</b> : ".$functie."<br /><b>Bedrijf</b> : ".$company."<br /><b>Adres</b> : ".$adres1.", ".$adres2."<br /><b>Email</b> : ".$from."<br><b>Telefoon</b> : ".$tel."<br /><b>Fax</b> : ".$fax."<br /><b>GSM</b> : ".$gsm."<br /><br /><b>Onderwerp</b> : ".$onderwerp."<br /><br /><b>Vraag</b><br />".$vraag.$body."</font>"; if (!empty($attachment)) { $body = "--$boundary Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 8bit $body --$boundary Content-type: $mimeType; name=$fileName Content-disposition: attachment; filename=$fileName Content-transfer-encoding: base64 $read --$boundary--"; } else $body = "--$boundary Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 8bit $body --$boundary--"; # Mailing the whole thing: if (mail($to, $subject, $body, $headers)) { echo($verzonden." <font face=verdana size=1><a href='#' onclick='javascript:window.close();'>venster sluiten</a></font>"); } else echo($probleem." <font face=verdana size=1><a href='#' onclick='javascript:window.history.back(-1);'>terug</a> <a href='#' onclick='javascript:window.close();'>venster sluiten</a></font>"); } else { echo($leeg." <font face=verdana size=1><a href='#' onclick='javascript:window.history.back(-1);'>terug</a></font>"); } } ?> anyone knows what's wrong? i'ld be very grateful... byebye |
|
#2
|
|||
|
|||
|
Okay before i even start looking at your code a couple of requests;
1) Please put [ PHP ] and [ / PHP ] tags around your php code (without the spaces) this put syntax highlighting on the code and makes it a LOT easier to read. and 2) Indenting, this is another way of improving readability, maybe add a couple of spaces when in braces. Please try editing your previous post to do this, not just posting again, as it keeps the thread clean. What is easier to read: <?php> if(condition){ dosomething; }else{ somethingelse} ?> or PHP Code:
I think most people would say the second one is easier to read, even if they disagree with my indenting(!)
__________________
http://www.phptutorials.cjb.net. go on, give it a click! |
|
#3
|
||||
|
||||
|
Quote:
In grenouille's defence, I believe the forum takes away the indenting when you post straight text without using [code] or [php] tags. solving the first problem [and possible re-pasting your code] will solve the second... unless grenouille's code wasn't indented to begin with =) grenouille: Is the linux machine one that you control, or is it an external hosting company? Are you sure it's set up to support mail(), and does it have a mail client running? |
|
#4
|
|||
|
|||
|
hello, it's me again, the central scrutinizer
![]() the problem seems to have solved itself. apparently it takes about 24 hours for the DNS to ... euhm, don't know what , to be fully functional once the site is uploaded.about indenting : i have been looking for that, but i didn't find how to do it, that's why it's all plain text. sorry about that. thanx anyway. always nice to know people actually read this stuff. byebye. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > php mailscript problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|