Witam, mam problem z generowaniem maili z załącznikiem. Chcę wysłac wizytówkę "*.vcf" za każdym razem wysłania formularza kontaktowego.
Jeśli tekst jest wpisany statycznie i nie ma zadeklarowanych zmiennych php, to po przyjściu maila jest tak jak powinno byc - wiadomośc + załącznik.
Jeśli natomiast dodam pierwsze 16 linijek poniższego kodu, to zamiast tworzyc maila z załącznikiem, przesyła mi maila z kodem źródłowym, bez załącznika.
Bez względu czy ustawię kodowanie strony na ANSI czy utf8 zawsze jest tak samo.
W czym tkwi błąd i jak go naprawic?
Oto kod:
<?php
//session_start();
include('funkcje.php');
//$db=polaczMy();
$nazwa = $_POST['nazwa'];
$vorname= $_POST['vorname'];
$strasse = $_POST['strasse'];
$kod = $_POST['kod'];
$tel = $_POST['tel'];
$mail = $_POST['mail'];
$datum_od = $_POST['datum_od'];
$datum_to = $_POST['datum_to'];
$ort = $_POST['ort'];
$zeit = $_POST['zeit'];
$mietteilung = $_POST['mietteilung'];
$service = $_POST['service'];
$to = 'jakis@mail.com';
$subject = 'Anfrage';
$headers = "From: xxx r\n";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = "BEGIN:VCARD
VERSION:3.0
N:".$vorname.";;;;
FN:".$vorname."
ORG:".$nazwa."
ADR;TYPE=work:;;".$strasse.";".$ort.";;;
EMAIL;type=INTERNET;type=WORK;type=internet:".$mail."
TEL;type=WORK;type=pref:".$tel."
END:VCARD";
?>
--PHP-mixed-
<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-
<?php echo $random_hash; ?>"
--PHP-alt-
<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-
<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-
<?php echo $random_hash; ?>--
--PHP-mixed-
<?php echo $random_hash; ?> Content-Type: text/vcard; name="attachment.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment
<?php echo $attachment; ?> --PHP-mixed-
<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ?
"Mail sent" : "Mail failed"; ?>
Pozdrwiam