Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    mail(): inserire immagini

    Ciao a tutti!

    Mi presento, sono Roberto, ho un piccolo negozio di PC e mi "diverto" a "giocare" con PHP

    Vorrei creare una piccola newsletter tramite PHP. O meglio l'ho già fatto. :master:

    Problema, non riesco ad allegare immagini da vedere subito...
    Ho provato a copiare il metodo che usa thunderbird per allegarle.

    Le invia ma non me le fa vedere

    Cosa posso fare?

    Metto quì il codice (un po' poco commentato, lo so... )

    codice:
    function boundary(){usleep(1);
    return '------------'.md5(uniqid(microtime()));}
    include '../td.php';
    top('Invio Newsletter');
    if(isset($_POST['body'])){$data_w = lista_week();
     $data_m = lista_mesi();
     $subject = 'Newsletter di '.$data_w[date('w')].' '.date('j').' '.$data_m[date('m')].' '.date('Y');
     $boundary= array('mail' => boundary(),
     'HTML' => boundary());
     $headers = "MIME-Version: 1.0
    From: Newletter - Computer Amico <newsletter@pc-friend.it>
    Reply-To: Computer Amico <negozio@pc-friend.it>
    X-Mailer: Gestiopen
    Content-type: multipart/alternative;
     boundary=\"{$boundary['mail']}\"";
    
     $body = "This is a multi-part message in MIME format.
    --{$boundary['mail']}
    Content-Type: text/plain; charset=UTF-8; format=flowed
    Content-Tranfer-Encoding: 7bit
    
    {$_POST['body']}
    
    --{$boundary['mail']}
    Content-Type: multipart/related;
     boundary=\"{$boundary['HTML']}\"
    
    --{$boundary['HTML']}
    Content-Type: text/html; charset=UTF-8
    Content-Transfer-Encoding: 7bit
    
    <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\">
    <html>
    	<head>
    	 <meta content=\"text/html;charset=UTF-8\" http-equiv=\"Content Type\">
    	 <title>$subject</title>
    	 <style>
    .cnt{text-align:center}
    h1{font:bold 20px fantasy;text-align:center}
    body{font:14px serif}
    	 </style>
    	</head>
    	<body>
    	<p class=\"cnt\">
    	 <img src=\"cid:part1.12345678.87654321@localhost.localdomain\" alt=\"Computer Amico\" />
    	</p>
    	<h1>$subject</h1>
    	
    
    ".entities_to('html',stripslashes(ucfirst($_POST['body'])))."</p>
    	</body>
    </html>
    --{$boundary['HTML']}
    Content-Type: image/png;
     name=\"loghino.png\"
    Content-Tranfer-Encoding: base64
    Content-ID: <part1.12345678.87654321@localhost.localdomain>
    Content-Disposition: inline;
     filename=\"loghino.png\"
    
    ".chunk_split(base64_encode(fread(fopen('../img/loghino.png','r'),filesize('../img/loghino.png')+1)))."--{$boundary['HTML']}--
    
    --{$boundary['mail']}--";
    
    faccio la mia query per prendere gli indirizzi
    e invio
    
    mail("$cognome $nome <$email>",$subject,$body,$headers)
    Penso che il problema sia dovuto al nome dichiarato alla fine (quando inserisco l'immagine)...
    Ma se non va bene uno assegnato come faccio a ricavarlo?

    Ringrazio in anticipo.
    Un salutone a tutti (ancora)

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    867
    Prova a prendere spunto da questa pillola:
    http://forum.html.it/forum/showthrea...hreadid=513009
    No pvt per sollecitare risposte, grazie.

  3. #3
    Eheh... Non l'avessi già fatto...

    Non devo allegare, ma inserire direttamente.

    L'allegato mi arriva, ma non risulta collegato, credo che l'errore sia nel nome del link o qualcosa del genere

    Non so proprio cosa fare... Intanto le collego dall'esterno come fanno tutti

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.