안녕하세요, 내가 최근에 smtp 파일을 사용하고 그물에 availble 모든 솔루션을 확인, 내 SMTP PHP는 메일 로컬 서버에서 작동하지 않습니다 내 서버의 웹 메일 작동 좋아. 나는 내 데이터베이스에 데이터를 삽입하고 그 데이터를 보내고 싶다. 관리자 이메일 주소 내 데이터가 데이터베이스에 삽입된다. 메일은 localhost에서 잘 작동하지만 서버에 오류가 있으면 서버에 연결하지 못한다. 난 내 호스팅 서버 지원 포럼 접촉하지만 그들은 여기에이 코드 문제 말을하는 것은SMTP 메일이 작동하지 않는 서버 작동 로컬 괜찮아요
$mail->SMTPDebug = 1;
또는
$mail->SMTPDebug = 2;
그럼 내 PHP 코드
<?php
if(isset($_POST['Isubmit'])){
$rname= $_POST['Iname'];
$remail= $_POST['Iemail'];
$rcontact= $_POST['Icontact'];
$rmessage= $_POST['Icomment'];
$rcourse= $_POST['Icourse'];
$date=date("Y-m-d");
$sql=mysqli_query($connect,"INSERT INTO enquiry(`NAME`,`EMAIL_ID`,`MOBILE_NO`,`COMMENT`,`SUBJECT`,`IS_DELETED`,`DATE`)VALUES('".$rname."','".$remail."','".$rcontact."','".$rmessage."','".$rcourse."','1','".$date."')");
//Mail Send Code
$ToEmail = '[email protected]';
$EmailSubject = 'Site contact form';
$MESSAGE_BODY = "Dear Sir/Mam,"."\n" ."\n"."New Contact Details are - "."\n"."\n";
$MESSAGE_BODY .= "Full Name: ".$rname."\n"."\n";
$MESSAGE_BODY .= "Email: ".$remail."\n"."\n";
$MESSAGE_BODY .= "Phone: ".$rcontact."\n"."\n";
$MESSAGE_BODY .= "Message: ".$rmessage."\n"."\n";
$MESSAGE_BODY .= "Course: ".$rcourse."\n"."\n";
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don'thave access to that date_default_timezone_set('Etc/UTC');
require 'PHPMailer-master/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging // 0 = off (for production use)
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "[email protected]";//"[email protected]";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";//"[email protected]";
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'Admin');
$mail->addAddress($ToEmail);
//Set the subject line
$mail->Subject = 'Enquiry Mail';
$mail->Body = $MESSAGE_BODY;//'this is test msg on 25-jun.';
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!<br>";
}
}
질문과 MySQL 사이의 관계를 친절하게 설명해 주시겠습니까? 고맙습니다. – FDavidov