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

    Php mailer: questo sconosciuto

    Ragazzi dopo avere creato un file con FPDF vorrei mandarlo con PHPmailer ad un indirizzo email.
    Non vi sto a riscrivere tutto il codice di FPDF comunque alla fine ho

    Codice PHP:
    $pdf->Cell(0,5,'Macchina: '.$variabilestampa[2],0,2,'L'); 
    $pdf->Cell(0,5,'Totale euro contratto: '.$variabilestampa[3],0,2,'L'); 
    $pdf->Cell(0,5,'Totale mesi contratto: '.$variabilestampa[4],0,2,'L'); 
    $pdf->Cell(0,5,'Altra voce: '.$variabilestampa[5],0,2,'L'); 
    $pdf->Cell(0,5,'Nr. mesi fatturati: '.$variabilestampa[6],0,2,'L'); 
    $pdf->Cell(0,5,'Totale euro nolo periodo : '.$variabilestampa[7],0,2,'L');
    $pdf->Cell(0,5,'Giorni trascorsi: '.$variabilestampa[8],0,2,'L'); 
    $pdf->Cell(0,5,'',0,2,'L'); 
    $pdf->Output(); 
    A questo punto vorrei mandare il file per mail. come posso fare?

    Grazie

  2. #2

  3. #3
    Ciao e grazie per la veloce risposta.
    Avevo già visto proprio quella pagina. Il browser mi rimane in caricamento fissa e non fa niente.
    Logicamente ho cambiato i parametri di indirizzo ecc.
    Ho Gmail, non devo configurare tipo il file ini o qualcosa di simile? Grazie

  4. #4
    Utente di HTML.it L'avatar di boots
    Registrato dal
    Oct 2012
    Messaggi
    1,626
    Se vuoi usare l'account di google, aggiungi questo:

    Codice PHP:
    $mail = new PHPMailer(); 
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug 1;  // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth true;  // authentication enabled
    $mail->SMTPSecure 'ssl'// secure transfer enabled REQUIRED for GMail
    $mail->Host 'smtp.gmail.com';
    $mail->Port 465
    $mail->Username GUSER;  // username
    $mail->Password GPWD;    // password 

  5. #5
    Con questo codice il browser mi va in loop e non fa niente.

    Ho modificato il codice in questo modo:

    [PHP]
    //$pdf->Output();
    // email stuff (change data below)
    $mail = new PHPMailer(); $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = miauser;
    // username
    $mail->Password =mia pass;
    // password // a random hash will be necessary to send mixed content
    $separator = md5(time()); // carriage return type (we use a PHP end of line constant)
    $eol = PHP_EOL; // attachment name $filename = "test.pdf"; // encode data (puts attachment in proper format)
    $pdfdoc = $pdf->Output("", "S"); $attachment = chunk_split(base64_encode($pdfdoc)); // main header
    $headers = "From: ".$from.$eol; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""; // no more headers after this, we start the body! //
    $body = "--

  6. #6
    Con questo codice il browser mi va in loop e non fa niente.

    Ho modificato il codice in questo modo:

    Codice PHP:
    //$pdf->Output(); 
    // email stuff (change data below) 
    $mail = new PHPMailer(); $mail->IsSMTP(); // enable SMTP 
    $mail->SMTPDebug 1// debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled 
    $mail->SMTPSecure 'ssl'// secure transfer enabled REQUIRED for GMail 
    $mail->Host 'smtp.gmail.com'
    $mail->Port 465
    $mail->Username miauser

    // username 

    $mail->Password =mia pass;
     
    // password // a random hash will be necessary to send mixed content 
    $separator md5(time()); // carriage return type (we use a PHP end of line constant) 
    $eol PHP_EOL// attachment name $filename = "test.pdf"; // encode data (puts attachment in proper format) 
    $pdfdoc $pdf->Output("""S"); $attachment chunk_split(base64_encode($pdfdoc)); // main header 
    $headers "From: ".$from.$eol$headers .= "MIME-Version: 1.0".$eol$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""// no more headers after this, we start the body! // 
    $body "--".$separator.$eol
    $body .= "Content-Transfer-Encoding: 7bit".$eol.$eol$body .= "This is a MIME encoded message.".$eol// message 
    $body .= "--".$separator.$eol;
     
    $body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol$body .= $message.$eol// attachment 
    $body .= "--".$separator.$eol$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol$body .= "Content-Transfer-Encoding: base64".$eol
    $body .= "Content-Disposition: attachment".$eol.$eol
    $body .= $attachment.$eol$body .= "--".$separator."--"// send message 
    mail($to$subject$body$headers); 

  7. #7
    Utente di HTML.it L'avatar di Ranma2
    Registrato dal
    Mar 2003
    Messaggi
    2,648
    Non usare gmail, gmail ha un limite massimo di invii giornalieri, usa il server locale.

    A prescindere da ciò, usa AddAttachment, così ti eviti problemi con la creazione degli header.

  8. #8
    Utente di HTML.it L'avatar di boots
    Registrato dal
    Oct 2012
    Messaggi
    1,626
    Visto che nella pagina fai 2(pdf, invio email) cose, vediamo di capire quale delle due manda il loop la pagina.

    1 Rimuovi la parte del invio della mail e controlla se il pdf viene creato correttamente(salvalo su disco).
    2 Rimuovi la parte della creazione del pdf e prova ad inviare una semplice mail

    Cmq dovresti dar retta a Ranma 1/2 ... usa il server locale

    PS:
    Codice PHP:
    ...
    $body .= "Content-Disposition: attachment".$eol.$eol;  
    $body .= $attachment.$eol$body .= "--".$separator."--"// send message  
    mail($to$subject$body$headers); 
    Ma se vuoi usare phpmailer, perchè chiami la mail()? dovresti usare la Send() di phpmailer

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.