PHPMailer 5.2.22 버전 적용
This commit is contained in:
71
plugin/PHPMailer/examples/contactform.phps
Normal file
71
plugin/PHPMailer/examples/contactform.phps
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* This example shows how to handle a simple contact form.
|
||||
*/
|
||||
|
||||
$msg = '';
|
||||
//Don't run this unless we're handling a form submission
|
||||
if (array_key_exists('email', $_POST)) {
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
require '../PHPMailerAutoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
//Tell PHPMailer to use SMTP - requires a local mail server
|
||||
//Faster and safer than using mail()
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'localhost';
|
||||
$mail->Port = 25;
|
||||
|
||||
//Use a fixed address in your own domain as the from address
|
||||
//**DO NOT** use the submitter's address here as it will be forgery
|
||||
//and will cause your messages to fail SPF checks
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
//Send the message to yourself, or whoever should receive contact for submissions
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
//Put the submitter's address in a reply-to header
|
||||
//This will fail if the address provided is invalid,
|
||||
//in which case we should ignore the whole request
|
||||
if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
|
||||
$mail->Subject = 'PHPMailer contact form';
|
||||
//Keep it simple - don't use HTML
|
||||
$mail->isHTML(false);
|
||||
//Build a simple message body
|
||||
$mail->Body = <<<EOT
|
||||
Email: {$_POST['email']}
|
||||
Name: {$_POST['name']}
|
||||
Message: {$_POST['message']}
|
||||
EOT;
|
||||
//Send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
//The reason for failing to send will be in $mail->ErrorInfo
|
||||
//but you shouldn't display errors to users - process the error, log it on your server.
|
||||
$msg = 'Sorry, something went wrong. Please try again later.';
|
||||
} else {
|
||||
$msg = 'Message sent! Thanks for contacting us.';
|
||||
}
|
||||
} else {
|
||||
$msg = 'Invalid email address, message ignored.';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Contact form</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Contact us</h1>
|
||||
<?php if (!empty($msg)) {
|
||||
echo "<h2>$msg</h2>";
|
||||
} ?>
|
||||
<form method="POST">
|
||||
<label for="name">Name: <input type="text" name="name" id="name"></label><br>
|
||||
<label for="email">Email address: <input type="email" name="email" id="email"></label><br>
|
||||
<label for="message">Message: <textarea name="message" id="message" rows="8" cols="20"></textarea></label><br>
|
||||
<input type="submit" value="Send">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@ -15,6 +15,7 @@
|
||||
<p>Russian text: Пустое тело сообщения</p>
|
||||
<p>Armenian text: Հաղորդագրությունը դատարկ է</p>
|
||||
<p>Czech text: Prázdné tělo zprávy</p>
|
||||
<p>Emoji: <span style="font-size: 48px">😂 🦄 💥 📤 📧</span></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -259,7 +259,7 @@ if (XRegExp) {
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Overriden native methods
|
||||
// Overridden native methods
|
||||
//---------------------------------
|
||||
|
||||
// Adds named capture support (with backreferences returned as `result.name`), and fixes two
|
||||
|
||||
@ -17,7 +17,7 @@ if (array_key_exists('userfile', $_FILES)) {
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
$mail->Subject = 'PHPMailer file sender';
|
||||
$mail->msgHTML("My message body");
|
||||
$mail->Body = 'My message body';
|
||||
// Attach the uploaded file
|
||||
$mail->addAttachment($uploadfile, 'My uploaded file');
|
||||
if (!$mail->send()) {
|
||||
|
||||
@ -12,7 +12,7 @@ if (array_key_exists('userfile', $_FILES)) {
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
$mail->Subject = 'PHPMailer file sender';
|
||||
$mail->msgHTML('My message body');
|
||||
$mail->Body = 'My message body';
|
||||
//Attach multiple files one by one
|
||||
for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) {
|
||||
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name'][$ct]));
|
||||
|
||||
Reference in New Issue
Block a user