Page 1 of 1

How to add an file in an php forum and send it to e-mail

Posted: Mon Oct 28, 2002 12:12 pm
by Skywalker
Does somebody know how to add an file in an php forum and let it proces it by the php code and let it send to your e-mail?

I have no Idea of doing this? Can give somebody some advice please or help me with it?

Posted: Wed Oct 30, 2002 3:30 am
by Skywalker
can enybody please help me with this thing, or give me at least some advice where to find more to do this.

My problems is how i can make an add file section in to an forum and send the compleets forum by e-mail with out opening eny Outlook.

I all ready have the forum with the php source, that works just fine, but how can i add a file to send it with the e-mail.

Posted: Wed Oct 30, 2002 6:07 am
by twigletmac
I'm not entirely clear on what you're trying to do, if you're trying to send an attachment using the mail() function, read this:
http://www.zend.com/zend/spotlight/send ... lpart1.php

Mac

Posted: Wed Oct 30, 2002 8:23 am
by Skywalker
This is what i have now. and I want to make a variable to add an attachmant.

<?php

// E-Mail

$mail_recipient_to="blabla@blabla.nl"; // erforderlich

$mail_recipient_cc=""; // optional

$mail_recipient_bcc=""; // optional

$mail_sender="Formmailer <>"; // optional

$mail_subject="Contact van Overige vragen formulier"; // optional

$mail_header_text="Goeden dag, er is een nieuwe overige vraag binnen gekomen: \n";

$mail_footer_text="De vraag is afkomstig van het overige vragen formulier";

$mail_copy_to_visitor =false; // false (keine Kopie) or true (Kopie senden)

$mail_visitor_details= true; // false (keine Details) or true (Details einfuegen)

// Formular

$form_redirect_page ="sample_redirectpage.html";

$form_check_fields["WelkNiveau"]="IS_EMPTY";

$form_check_fields["Naam"]="CONTAINS_NUMBERS";

$form_check_fields["Straat"]="CONTAINS_NUMBERS";

$form_check_fields["Welk-vak"]="IS_EMPTY";

$form_check_fields["Welk-pakket"]="IS_EMPTY";

$form_check_fields["Telefoon"]= "CONTAINS_CHARACTERS";

$form_check_fields["EMail"]="INVALID_EMAIL";

$form_check_fields["DatumTentame"]="IS_EMPTY";

$page_error_header="form_error_header.html";

$page_error_footer="form_error_footer.html";

?>

THX Very Much for helping me

Posted: Wed Oct 30, 2002 8:29 am
by twigletmac
That's a configuration file so adding a variable there won't allow you to add attachments to mail messages. A variable just stores information - it doesn't do anything else. You need to find the part of the code dealing with e-mailing and add code to allow attachments there. Read the zend article I posted a link to earlier for more information on sending attachments using PHP.

Mac

Posted: Wed Oct 30, 2002 8:30 am
by Skywalker
ok thx I am going to try it :D

Posted: Fri Nov 01, 2002 5:36 am
by Skywalker
<body bgcolor="#CCCCFF"><?php



/************************************************************************

* File: licomail_functions.inc.php *

* Function-Library *

* ===================================================================== *

* Beschreibung: *

* Diese Datei stellt die Funktionalitaet des Formmailers zur Ver- *

* fuegung. *

* *

* Dokumentation und Support: *

* http://www.little-coder.ch *

* ===================================================================== *

* Author: Roger Wittwer Letzte Aenderung: 10/02/2002 *

* Copyright (c) 2002 by Roger Wittwer *

************************************************************************/



$inputVars; // Input aus dem Formular



/*******************************************************************

* Die Methode liefert den Namen der Konfigurations-Datei,

* welcher mit dem Hidden Field im Formular verschickt wurde

*

* Return: Name der Konfigurations-Datei

*******************************************************************/

function getFormConfigFile()

{

global $inputVars;

return $inputVars["licomail_config_file"];

}



/*******************************************************************

* Die Methode bereitet den Inhalt des E-Mails auf und gibt

* ihn als String zurueck

*

* Return: E-Mail-Body

*******************************************************************/

function generateEMailBody()

{

global $inputVars,

$mail_header_text,

$mail_footer_text,

$mail_visitor_details;



while (list($Key, $Val) = each($inputVars)) {

if ($Key !="licomail_send" && $Key !="licomail_config_file")

{

$body .= $Key.": ".$Val."\n";

}

}



if ($mail_visitor_details)

{

$languages = array(

"de" => "Deutsche Version",

"en" => "Englische Version",

"nl" => "Niederländische Version",

"fr" => "Französische Version",

"it" => "Italienische Version",

"ru" => "Russische Version",

);



$header = @getallheaders();

$host = @gethostbyaddr($GLOBALS[REMOTE_ADDR]);

$os = getVisitorOS($header['User-Agent']);

list( $browser, $version, $language ) = getVisitorBrowser($header['User-Agent']);

$body .= "\n\n Bezoeker details:";



if (browser)

{

$body .= "\nBrowser: ".$browser;

if ($version) $body .= " ".$version;

if ($languages[$language]) $body .= " (".$languages[$language].")";

}



if ($os) $body .= "\nGebruikte systeem: ".$os;

if ($host) $body .= "\nHerkomst-Adres / IP: ".$host;

}

return $mail_header_text."\n\n".$body."\n\n".$mail_footer_text;

}



/*******************************************************************

* Die Methode bereitet den E-Mail-Header auf und gibt

* ihn als String zurueck

*

* Return: E-Mail-Header

*******************************************************************/

function generateEMailHeader()

{

global $mail_recipient_cc,

$mail_recipient_bcc,

$mail_sender,

$mail_copy_to_visitor;



if ($mail_sender) $headers = "From: ".$mail_sender."\n";

if ($mail_recipient_cc) $headers .= "cc: ".$mail_recipient_cc;

if ($mail_copy_to_visitor && getVisitorEMailAdress() != "")

{

if ($mail_recipient_cc) $headers .= ", ";

else $headers .= "cc: ";

$headers .= getVisitorEMailAdress();

}

$headers .= "\n";

if ($mail_recipient_bcc) $headers .= "bcc: ".$mail_recipient_bcc;



return $headers;

}



/*******************************************************************

* Die Methode filtert die vom Besucher eingetragene E-Mail-

* Adresse aus dem Formular.

*

* Hinweis: Beruecksichtigt wird die erste gueltige E-Mail-Adresse,

* in einem Eingabefeld des Formulars.

*

* Return: E-Mail-Adresse

*******************************************************************/

function getVisitorEMailAdress()

{

global $inputVars;



reset($inputVars);

while (list($Key, $Val) = each($inputVars))

{

if (preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.([a-zA-Z]{2,3})$/", $Val))

{

return $Val;

}

}

return "";

}



/*******************************************************************

* Die Methode prueft die Eingaben des Besuchers

*

* Return: Array mit Fehlermeldungen

*******************************************************************/

function checkInputVars()

{

global $inputVars,

$form_check_fields;



$retErrors;



if (isset($form_check_fields))

{

$keys = array_keys($form_check_fields);

for ($i = 0; $i < count($form_check_fields) ;$i++)

{

$inputName = $keys[$i];

$inputValue = $inputVars[$inputName];

$errorPattern = $form_check_fields[$inputName];



if($inputValue == "")

$retErrors[] = $inputName.": Dit veld heeft een corecte ingave nodig";



if ($errorPattern == "CONTAINS_NUMBERS")

{

if (preg_match("/^.*[0-9].*$/", $inputValue))

$retErrors[] = $inputName.": Je ingave mag geen cijfers bevatten";

}

else if ($errorPattern == "CONTAINS_CHARACTERS")

{

if (preg_match("/^.*[a-zA-Zäöü].*$/", $inputValue))

$retErrors[] = $inputName.": Je ingave mag geen hoofd letters bevatten";

}

else if ($errorPattern == "INVALID_EMAIL" && !$inputValue == "")

{

if (!preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.([a-zA-Z]{2,3})$/", $inputValue))

$retErrors[] = $inputName.": Je e-mail adres is ongeldig";

}

}

}

return $retErrors;



}





/*******************************************************************

* Diese Methode ermittelt das Betriebssystem aufgrund des Browsers

*

* Diese Methode habe ich nach einem Hinweis vom Author in der

* deutschen PHP-Mailingliste kopiert:

* http://pfirsich.altmuehlnet.de/auswertung.php3

* http://pfirsich.altmuehlnet.de/auswert.php3

*

* Herzlichen Dank!

*

* Return: Betriebssystem

*******************************************************************/

function getVisitorOS($ua) {

if( eregi( "Win {0,1}(nt|[0-9]{1,2})", $ua, $win_ver ) ) {

$win_ver = $win_ver[1];

$os = "Windows";

}

if( eregi( "Windows {0,1}(nt|[0-9]{1,2})", $ua, $win_ver ) ) {

$win_ver = $win_ver[1];

$os = "Windows";

}

if( $win_ver ) $win_ver = trim( $win_ver );

if( $win_ver == "95" ) $os .= " 95";

elseif( $win_ver == "98" ) $os .= " 98";

elseif( $win_ver == "16" || ereg( "^3\.", $win_ver ) ) $os .= " 16";

elseif( eregi( "nt", $win_ver ) || ereg( "4\..+", $win_ver ) ) $os .= " NT";

if( ereg( "Linux", $ua ) ) {

$os = "Linux";

if( ereg( "Linux ([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3})", $ua, $os_ver ) ) $os .= "$os_ver[1]";

}

if( ereg( "SunOS", $ua ) ) $os = "SunOS";

if( ereg( "([a-zA-Z]{3,4}BSD)", $ua, $os ) ) $os = $os[1];

if( ereg( "OS/2", $ua ) ) $os = "OS/2";

if( ereg( "Mac", $ua ) ) $os = "MacOS";

return( $os );

}



/*******************************************************************

* Diese Methode ermittelt den Browser

*

* Diese Methode habe ich nach einem Hinweis vom Author in der

* deutschen PHP-Mailingliste kopiert:

* http://pfirsich.altmuehlnet.de/auswertung.php3

* http://pfirsich.altmuehlnet.de/auswert.php3

*

* Herzlichen Dank!

*

* Return: Array mit Browser, Version und Sprache

*******************************************************************/

function getVisitorBrowser($ua) {

list( $browser, $version ) = split( "/", $ua, 2 );

$ua = $version;

if( $browser == "Mozilla" ) {

list( $version, $ua ) = split( " ", $ua, 2 );

$moz_browser = true;

$browser = Netscape;

if (eregi("5.", $version)) $version = "6.x";

$moz_ver = $version;

if( ereg( "\[([a-z]{2})\]", $ua, $language ) ) $language = $language[1];

if( eregi( "MSIE", $ua ) ) {

$browser = "Internet Explorer";

if( eregi( "MSIE ([0-9]\..+);", $ua, $version ) ) $version = $version[1];

}

if( eregi( "Opera", $ua) ) {

$browser = "Opera";

if( eregi( "Opera[/ ]([0-9]\..+);", $ua, $version ) ) $version = $version[1];

if (eregi("5.", $version)) $version = "6.x";

}

}

return array( $browser, $version, $language );

}









?>


Is the forum mail sender? If it is sow how the hell can I put in ths MIME funcion. I really don't understand enything of this MIME function

Posted: Fri Nov 01, 2002 5:45 am
by twigletmac
Have you tried e-mailing the author of the code for support?

Mac