Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Fractals87
    Registrato dal
    Apr 2008
    Messaggi
    1,202

    [PHP] Mail con php da hosting

    Ciao a tutti è da un po di giorni che cerco una soluzione in merito all'invio di mail da hosting.

    presupponendo che le configurazioni del php.ini sono standard e percio non definite a mio piacimento senza poterlo modificare come posso usare la funzione mail() di php per l'invio della mail usando appunto la casella di posta elettronica che l'hosting mi ha dato?

    Grazie a tutti ciao ciao

  2. #2
    Utente di HTML.it L'avatar di Fractals87
    Registrato dal
    Apr 2008
    Messaggi
    1,202
    Ciao a tutti dopo estenuanti ricerche ho trovato questo script e sembra funzionare.... pero a me nn piace vomitare righe di codice con copia incolla senza sapere assolutamente cosa sia...
    Non c'e un modo molto piu semplice per inviare una banale email automatica?

    Codice PHP:
    $smtp_server "smtp.miodominio.it"# Il server SMTP a cui vogliamo collegarci
    $port "25"# Porta del server...generalmente è la 25
    $timeout "30"# Tempo di attesa per la risposta del server
    $username "mioindirizzo@miodominio.it"# La vostra username
    $password "miapassword"# La vostra password
    $localhost "localhost"# Indirizzo dell'host ospitante
    $newLine "\r\n"# Servirà per andare a capo nei comandi Telnet


    $smtpConnect fsockopen($smtp_server$port$errno$errstr$timeout);
    $smtpResponse fgets($smtpConnect515);
    if(empty(
    $smtpConnect))
    {
    $output "Failed to connect: $smtpResponse";
    return 
    $output;
    }
    else
    {
    $logArray['connection'] = "Connected: $smtpResponse";
    }


    #Diciamo al server che vogliamo autenticarci
    fputs($smtpConnect,"AUTH LOGIN" $newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['authrequest'] = "$smtpResponse";


    # Invio username
    fputs($smtpConnectbase64_encode($username) . $newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['authusername'] = "$smtpResponse";

    # Invio password
    fputs($smtpConnectbase64_encode($password) . $newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['authpassword'] = "$smtpResponse";


    fputs($smtpConnect"HELO $localhost$newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['heloresponse'] = "$smtpResponse";


    # Indico il mittente
    fputs($smtpConnect"MAIL FROM: $email$newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['mailfromresponse'] = "$smtpResponse";

    # Indico il destinatario
    fputs($smtpConnect"RCPT TO: $to$newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['mailtoresponse'] = "$smtpResponse";

    # Indico che ora voglio scrivere l'e-mail
    fputs($smtpConnect"DATA" $newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['data1response'] = "$smtpResponse";

    # Costruisco l'Headers
    $headers "MIME-Version: 1.0" $newLine;
    $headers .= "Content-type: text/html; charset=iso-8859-1" $newLine;
    $headers .= "To: $to <$to>" $newLine;
    $headers .= "From: $nome $cognome <$email>" $newLine;

    # Invio l'e-mail
    fputs($smtpConnect"To: $to\nFrom: $email\nSubject: $subject\n$headers\n\n$body\n.\n");
    $smtpResponse fgets($smtpConnect515);
    $logArray['data2response'] = "$smtpResponse";

    fputs($smtpConnect,"QUIT" $newLine);
    $smtpResponse fgets($smtpConnect515);
    $logArray['quitresponse'] = "$smtpResponse";
    ?> 

  3. #3
    Utente di HTML.it L'avatar di Razorblade
    Registrato dal
    Feb 2002
    Messaggi
    1,308
    Ti sei complicato la vita.
    Usa la libreria open PhpMailer, prova a fare una ricerca.
    Ciao

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.