61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
|
|
<?php
|
|
require("class.phpmailer.php");
|
|
function get_include_contents($filename, $variablesToMakeLocal) {
|
|
extract($variablesToMakeLocal);
|
|
if (is_file($filename)) {
|
|
ob_start();
|
|
include $filename;
|
|
return ob_get_clean();
|
|
}
|
|
return false;
|
|
}
|
|
if( isset($_GET['submit']) )
|
|
|
|
|
|
$mail = new PHPMailer();
|
|
$mail->IsSMTP();
|
|
$mail->SMTPAuth = true;
|
|
$mail->SMTPSecure = 'tls';
|
|
$mail->Host = "smtp.gmail.com";
|
|
$mail->Port = 587;
|
|
$mail->IsHTML(true);
|
|
$mail->Username = "username@gmail.com";
|
|
$mail->Password = "password";
|
|
$mail->SetFrom("from@gmail.com");
|
|
$mail->AddAddress(htmlentities($_GET['val1']));
|
|
$variable['one'] = 'my variable one';
|
|
$variable['two'] = 'my variable two';
|
|
$mail->IsHTML(true);
|
|
$mail->Subject = (htmlentities($_GET['val2']));
|
|
$mail->Body = get_include_contents('sample.php', $variable);
|
|
$mail->Send();
|
|
|
|
if(!$mail->Send())
|
|
{
|
|
echo "Mailer Error: " . $mail->ErrorInfo;
|
|
}
|
|
else
|
|
{
|
|
echo "Message has been sent";
|
|
}
|
|
?>
|
|
|
|
|
|
<?php if( isset($result) ) echo $result; //print the result above the form ?>
|
|
|
|
|
|
<form action="" method="get">
|
|
Inserisci number1:
|
|
<input type="text" name="val1" id="val1"></input>
|
|
|
|
<?php echo "ciaoooo"; ?>
|
|
|
|
<br></br>
|
|
Inserisci number2:
|
|
<input type="text" name="val2" id="val2"></input>
|
|
|
|
<br></br>
|
|
|
|
<input type="submit" name="submit" value="send"></input>
|
|
</form>
|