come mettere allegati in un mms

Supergatto

Nuovo Utente
14 Gen 2008
11
0
0
Non so come mettere gli allegati in uno script php per inviare mms ho messo il destinatario il testo il mittente e funzionano, mi dite cosa devo fare per mettere gli allegati nel php :crying:
 
Ultima modifica:

Supergatto

Nuovo Utente
14 Gen 2008
11
0
0
Ti sembrera una domanda stupida ma mi dici quali codici devo scrivere solo per l'allegato perchè non mi funziona

codice php:
<?php
if (isset($_POST["submit"])){
$a = $_POST['a'];
$da = $_POST['da'];
$obj = $_POST['obj'];
$testo = $_POST['testo'];

$attachment = $_FILES['attachment']['tmp_name'];
$attachment_type = $_FILES['attachment']['type'];
$attachment_name = $_FILES['attachment']['name'];

$intestazioni = "From: " . $da;
$messaggio = "";

if (is_uploaded_file($attachment))
{
$file = fopen($attachment,'rb');
$data = fread($file, filesize($attachment));
fclose($file);
$data = chunk_split(base64_encode($data));
$rand = md5(time());
$boundary = "==Multipart_Boundary_x{$rand}x";

$intestazioni .= "\nMIME-Version: 1.0\n";
$intestazioni .= "Content-Type: multipart/mixed;\n";
$intestazioni .= " boundary=\"{$boundary}\"";

$messaggio .= "This is a multi-part message in MIME format.\n\n";
$messaggio .= "--{$boundary}\n";
$messaggio .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$messaggio .= "Content-Transfer-Encoding: 7bit\n\n";
$messaggio .= $testo . "\n\n";
$messaggio .= "--{$boundary}\n";
$messaggio .= "Content-Disposition: attachment;\n";
$messaggio .= " filename=\"{$attachment_name}\"\n";
$messaggio .= "Content-Transfer-Encoding: base64\n\n";
$messaggio .= $data . "\n\n";
$messaggio .= "--{$boundary}--\n";
}
else{
$messaggio = $testo;
}

if (mail($a, $obj, $messaggio, $intestazioni))
{
echo "Messaggio inviato con successo.";
}else{
echo "Si &egrave; verificato un errore nell'invio.";
}
}else{
?>

<form action="<? echo $_SERVER['PHP_SELF']; ?>"
method="POST" enctype="multipart/form-data">
Destinatario:
<input type="text" name="a"><br>
Mittente:
<input type="text" name="da"><br>
Oggetto:
<input type="text" name="obj" style="height: 22px"><br>
Messaggio:
<textarea name="testo"></textarea><br>
Allega file:
<input type="file" name="attachment"><br>
<input type="submit" name="submit" value="Invia" />
</form><?
}
?>

di tutto questo codice cosa devo scrivere?
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
K Mettere insieme due funzioni Javascript 2
Shyson Mettere categorie nelle anteprime degli articoli PHP 1
R Mettere in sicurezza una comunicazione .NET Framework 0
G Mettere il footer in basso HTML e CSS 0
G mettere account posta in Microsoft outlook 2016 di gmail Posta Elettronica 0
B Mettere sito offline senza troppe penalizzazioni SEO e Posizionamento 0
G [HTML] mettere link in facebook link invece che su sito web Social Media Marketing 1
G [Guida MyBB 1.8] Mettere in colonna SubForum CMS (Content Management System) 0
G [Photoshop] Mettere una scritta in prospettiva. Photoshop 7
Shyson [PHP] Mettere parentesi graffe o no? PHP 2
Shyson [PHP] Mettere placeholder PHP 2
Shyson [HTML] Mettere select responsive HTML e CSS 3
giannit [HTML] Mettere div al posto di iframe e possibile? HTML e CSS 9
D cambio il dominio per mettere keyword dentro? SEO e Posizionamento 8
G [HTML] mettere menu style smartphone anche sui tablet HTML e CSS 0
Shyson [PHP] Mettere il link "Leggi tutto" PHP 0
L mettere un simbolo per capire se è un sottomenu jQuery 2
Shyson [WordPress] Mettere un limite a lunghezza caratteri WordPress 11
Shyson [WordPress] Mettere classe css WordPress 0
Shyson Mettere span davanti a php PHP 9
F [VENDO] Inviti a mettere mi piace alla vostra pagina facebook! Annunci servizi di Social Media Marketing 10
Shyson Mettere contaviste ai miei articoli PHP 1
A Come mettere il target _blank in un parser xml in php? PHP 1
A Come mettere al sicuro un Cloud Server? Cloud Computing e Cloud Server 1
Shyson Mettere spazio a codice PHP 3
A Miglior hosting per mettere su internet un sito HTML? Hosting 3
A posso mettere i miei contenuti di un sito usa in un sito in australia SEO e Posizionamento 2
P mettere al centro i bottoni HTML e CSS 10
V Quando mettere il JOIN e quando no? MySQL 1
I Vendo 32.000 Inviti a mettere mi piace alle pagine/Invito Eventi Annunci servizi di Social Media Marketing 0
R Mettere la possibilità di Salvare in un gioco =) Come si fa? Java 2
C è illegale mettere sul proprio portfolio online i siti fatti sotto contratto? Discussioni Varie 5
max_400 Hosting gratuito dove mettere giochi in flash Hosting 2
M Mettere un'immagine come header HTML e CSS 1
Shyson Mettere più valori in una variabile PHP 1
Shyson Mettere css jQuery 1
E Mettere come Selected l'opzione di un select option, tramite il dato di una query. Javascript 2
A consiglio su come mettere in evidenza un contenuto Webdesign e Grafica 0
Shyson Mettere target="_top" PHP 0
Mauro Guardiani chi sa dove mettere questo codice Tubular jQuery plugin Javascript 1
Shyson Mettere "I più visti" nel sito Snippet PHP 0
Shyson Mettere script nel Database PHP 0
Shyson Mettere nel sito "I più visti" PHP 9
S Come mettere Menu a tendina in un modello CSS? HTML e CSS 0
F mettere online foto di persone, si può? Leggi, Normative e Fisco 2
Shyson Mettere alt e title in immagine nel css HTML e CSS 2
Shyson Mettere hover a css in linea HTML e CSS 1
Shyson Mettere immagine per chiudere popup HTML e CSS 1
P Mettere in una riga i record di una colonna MySQL 0
Shyson Mettere url collegato al radio HTML e CSS 20

Discussioni simili