SMTP가있는 phpmailer를 내 사이트에 추가합니다. 필자는 phpmailer 파일을 만들었고 필요한 모든 코딩 작업을 완료했습니다. 이제 필자의 phpmiler.php를 index.html에 올바르게 추가하여 이메일 형식을 사용할 수 있어야합니다.phpmailer를 HTML 양식에 추가하십시오.
내 phpmailer.php :
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'assets/PHPMailer/src/Exception.php';
require 'assets/PHPMailer/src/PHPMailer.php';
require 'assets/PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'test'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test'; // SMTP username
$mail->Password = 'test'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom('test');
$mail->addAddress('test'); // Add a recipient
$mail->addReplyTo('test', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
나는 모든 것을 내가 개인 정보 필드에 TEST를 사용, 작동, PHP 파일을 테스트했다.
내 HTML 양식 : 내 phpmailer.php으로 이메일, 텍스트와 제목을 소요하고 메시지를 던져 HTML 양식을 보낼 수 있도록
<div class="block">
<h2>Send message</h2>
<form>
<div class="form-group">
<input type="text" name="mail" class="form-control" placeholder="Email Address">
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group">
<textarea class="form-control" name="text" rows="3" placeholder="Your Message"></textarea>
<button class="btn btn-default" type="submit" >Send Message</button>
</div>
</form>
</div>
어떻게이 일을해야합니까?
내 언어가 아닌 고맙고 죄송합니다.