PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 3rd, 2005, 04:03 PM
grenouille grenouille is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 34 grenouille User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 48 sec
Reputation Power: 5
Exclamation php mailscript problem

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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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 .= "&nbsp;&nbsp;Naam - niet ingevuld<br>";
}
if(empty($fname)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Voornaam - niet ingevuld<br>";
}
if(empty($onderwerp)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Onderwerp - niet ingevuld<br>";
}
if(empty($vraag)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Vraag - niet ingevuld<br>";
}
if(empty($functie)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Functie - niet ingevuld<br>";
}
if(empty($company)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Naam bedrijf - niet ingevuld<br>";
}
if(empty($adres1) || empty($adres2)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Adres - niet ingevuld<br>";
}
if(empty($from)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;Email - niet ingevuld<br>";
$meel = 1;
}
if(empty($tel)) {
$count = $count + 1;
$leeg .= "&nbsp;&nbsp;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 .= "&nbsp;&nbsp;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 .= "&nbsp;&nbsp;Bestand - verkeerd bestandstype (toegelaten : doc, xls, txt en pdf)<br />";
$count .= 1;
}
}
}
}
$sfile = $_FILES['attachment']['size'];
if ($sfile > 500000) {
$leeg .= "&nbsp;&nbsp;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."&nbsp;&nbsp;<font face=verdana size=1><a href='#' onclick='javascript:window.close();'>venster sluiten</a></font>");
}
else echo($probleem."&nbsp;&nbsp;<font face=verdana size=1><a href='#' onclick='javascript:window.history.back(-1);'>terug</a>&nbsp;&nbsp;&nbsp;<a href='#' onclick='javascript:window.close();'>venster sluiten</a></font>");
}
else {
echo($leeg."&nbsp;&nbsp;<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

Reply With Quote
  #2  
Old January 4th, 2005, 06:00 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
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:
<?php
  
if( condition )
  {
    
dosomething;
  } 
  else
  {
    
dosomethingelse;
  }
?>


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!

Reply With Quote
  #3  
Old January 4th, 2005, 09:19 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Quote:
Originally Posted by mattp23
2) Indenting, this is another way of improving readability, maybe add a couple of spaces when in braces.

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?

Reply With Quote
  #4  
Old January 4th, 2005, 01:15 PM
grenouille grenouille is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 34 grenouille User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 48 sec
Reputation Power: 5
Thumbs up thanx guys

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.
PHP Code:
 aha!! found it

thanx anyway. always nice to know people actually read this stuff.

byebye.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > php mailscript problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT