phpmailer

Pubblicità

Skills07

Head of Development
Staff Forum
Utente Èlite
Messaggi
39,454
Reazioni
13,349
Punteggio
253
salve ragazzi

sto sviluppando un sito web php.

stamane ho fatto questo e funziona riesco a mandare la mail con un indirizzo settato in modo definitivo, però vorrei renderlo variabile:

sulla mia main page ho questo panel

HTML:
<div id="panel-email" class="modal" style="z-index:99999;">

        <div id="container" style="display:block;">
            <form action ="sendmailwebsite.php" method="POST">
            <img id="image" src="immagini/immaginiprova/background.png" />
            <p id="text">
                <img id="password_forgot" src="immagini/forgot.png" style="width:90%; margin-left:5%;"/>
                <br>
                <br>
                <br>
                <label for="email_address" style="font-family: foo; font-size:40px; margin-left: 10%;">Email:</label>
                <br>
                <br>
                <input type="text" id="email-recovery" class="textField" style="width:620px; height:42px;  margin-left: 10%; font-size:25px; font-family: 'Fontdiner Swanky', cursive;"/>
                <br>
                <br>
                <!--<img id="ok" src="immagini/ok.png"  style="width:30%;margin-top:20%; margin-left: 35%;" />-->
                <input type="image" value="send" src="immagini/ok.png" alt="Submit" style="width:30%; float:right;margin-top: 20%; margin-right:35%;"
            </p>
            </form>


come vedete richiama un sendmailwebsite.php


ed ora vi mostro quello script php

PHP:
require_once('scripts/php_scripts/mail_prova/class.phpmailer.php');
require_once('scripts/php_scripts/mail_prova/class.smtp.php');
require_once('scripts/php_scripts/mail_prova/class.pop3.php');
require_once('scripts/php_scripts/mail_prova/class.phpmaileroauthgoogle.php');
require_once('scripts/php_scripts/mail_prova/class.phpmaileroauth.php');



$address = "";



    $mail = new PHPMailer();

    $body = "<html>
            <head>
            <title>You have requested to change your password, because you have forgot it!</title>
            </head>
            <body>
            <p>To change the password you need to click this link and then go to change it!</p>
            <table>
            <tr>
           
            </tr>
            <tr>
            <td>Link of the email</td>
            <td><a href=\"#\">guesswholink</a></td>
            </tr>
            </table>
            </body>
            </html>";
//$body             = eregi_replace("[\]",'',$body);

    $mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host       = "ssl://smtp.gmail.com"; // SMTP server
    $mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
    // 1 = errors and messages
    // 2 = messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "lavagnacondivisa@gmail.com";  // GMAIL username
    $mail->Password   = "lavagna2016";            // GMAIL password

    $mail->SetFrom('guesswho@gmail.com', 'GuessWho the game');

//$mail->AddReplyTo("user2@gmail.com', 'First Last");

    $mail->Subject    = "Request Changing Password";

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

    $mail->MsgHTML($body);

    //$address = "christian.cortese.cc@gmail.com";
    $mail->AddAddress($address, "user");

//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
    }

vorrei valorizzare address con il campo di input impostato nel pannello sopra come faccio??
 
Sostituisci questa riga :
HTML:
 <input type="text" id="email-recovery" class="textField" style="width:620px; height:42px;  margin-left: 10%; font-size:25px; font-family: 'Fontdiner Swanky', cursive;"/>
con :
HTML:
 <input type="text" name="email" id="email-recovery" class="textField" style="width:620px; height:42px;  margin-left: 10%; font-size:25px; font-family: 'Fontdiner Swanky', cursive;"/>
e poi alla variabile $address ottieni il testo di email ( che ho aggiunto io) con $_POST
PHP:
$address = $_POST['email'];

fammi sapere se funziona dai
 
Ultima modifica:
Pubblicità
Pubblicità
Indietro
Top