0
첨부 파일 (그림)이있는 양식을 우편으로 보내려고합니다. 그러나 나는 그것을 작동시킬 수 없습니다. 나는 거의 모든 것을 시험해 보았다. 작동하게 할 한 가지를 exept했다 : 그리고 구글과 유튜브를 모두 검색하라.메일 첨부 양식
그림이 표시되지만 사용자 이름이나 도시는 표시되지 않습니다.
누군가 나를 도와주세요. 제가 잘못했거나 누락 된 것을 모릅니다.
<?php
if(isset($_POST['terms'])){
$email_to = "[email protected]";
$email_subject = "Subject";
$user = $_POST['user']; // required
$city = $_POST['city']; // required
/*********Creating Uniqid Session*******/
$txtSid = md5(uniqid(time()));
$headers = "";
$headers .= "From: ".$_POST["fieldFormName"]."<".$_POST["fieldFormEmail"].">\nReply-To: ".$_POST["fieldFormEmail"]."";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$txtSid."\"\n\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "--".$txtSid."\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$headers .= $email_message."\n\n";
/***********Email Attachment************/
if($_FILES["attachment"]["name"] != "")
{
$txtFilesName = $_FILES["attachment"]["name"];
$txtContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"]["tmp_name"])));
$headers .= "--".$txtSid."\n";
$headers .= "Content-Type: application/octet-stream; name=\"".$txtFilesName."\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"".$txtFilesName."\"\n\n";
$headers .= $txtContent."\n\n";
}
$email_message = "Message.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "User: ".clean_string($user)."\n";
$email_message .= "City: ".clean_string($city)."\n";
// Send
@mail($email_to, $email_subject, $email_message, $headers);
}else{
echo "You need to accept our terms";
}
?>
github의 간단한 예제를 따르고 있습니다. https://github.com/PHPMailer/PHPMailer 이 오류가 계속 표시됩니다. 메시지를 보낼 수 없습니다. 메일 오류 : SMTP connect()가 실패했습니다. 이메일이 메일로 전송되고 있습니다 ... SMPT 정보가 정확합니다 .. 내 서버 지원에서 가져 왔습니다. 의견이 있으십니까? – user2254488
새 코드로 질문을 업데이트하거나 새 질문을 시작하십시오. smtp 서버가 올바르지 않다는 SMTP 연결() 오류로 인해 질의가 제기됩니다. 지원 팀의 세부 공급자에게 문의하십시오. –
내 코드가 포함 된 새로운 질문을 여기에 게시했습니다 : http://stackoverflow.com/questions/21168643/phpmailer-help-getting-smtp-error-but-mail-is-send 감사합니다. – user2254488