일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- javascript
- UML
- chart.js
- dovecot
- curl
- C#
- 자바스크립트
- 안드로이드 푸시
- mysql
- roundcube
- FCM
- Mail Server
- html5
- php 취약점
- 설치
- WebView
- 안드로이드 푸쉬
- 안드로이드 gcm
- C# IO
- 우분투
- android 효과음
- xe
- 안드로이드
- 폼메일
- php 시큐어코딩
- not working
- Android
- soundpool
- PHP
- 자동 생성
- Today
- Total
그러냐
php 폼메일 소스 mail() 본문
1. 간단 소스
출처 : https://www.mireene.com/index.php?pid=service_faq/faq_view&uid=136&c1_uid=3&page=&keyword=
2. 한메일 보내지는 소스
1번소스도 되는듯?
주석때문에 지져분한데 적당히 수정해서 쓰시길
1)
$tit = iconv('utf-8','euc-kr',$_POST["subject"]);
$tit = $_POST["subject"];
$text = $_POST["content"];
$receiver_email = $_POST["mailadd"]; //받는 사람
$receiver = $_POST["mailname"];
$receiver ='';
$receiver_email = ""; //받는 사람 Emai
$email = 'bononara@mailplug.co.kr';
$name = iconv('utf-8','euc-kr','관리자');
$name ='관리자';
// $text = addslashes($text);
// $body = nl2br($text);
$vl = xmail('html',$receiver_email,$receiver,$email,$name,$tit,$text);
// $mailheaders = "Return-Path: $email\r\n";
// $mailheaders .= "From: $name <$email>\r\n";
//
// $mailheaders .= "Content-Type: text/html; charset=utf-8\r\n";
// $bodytext = stripslashes($body);
//mail($receiver_email,$tit,$bodytext,$mailheaders,"-f bonjung.co.kr");
// $vl = mail($receiver_email,$tit,$bodytext,$mailheaders,"-f mailplug.co.kr");
if($vl==1){
echo "ok";
}else{
echo "failed";
}
function xmail($type,$to,$to_name,$from,$from_name,$title,$message,$charset="utf-8")
{
global $_FILES;
if($type!='html'){
$message = nl2br($message);
$contentType = "Content-Type: text/plain; charset=\"$charset\"; format=flowed";
}else{
$contentType = "Content-Type: text/html; charset=\"$charset\"";
}
$boundary = '----='.uniqid(rand(),true);
$title = "=?$charset?B?".base64_encode($title)."?=";
$from_name = "=?$charset?B?".base64_encode($from_name)."?=";
$to_name = "=?$charset?B?".base64_encode($to_name)."?=";
$recipient = sprintf("%s <%s>", $to_name, $to);
$headers = sprintf(
"From: %s <%s>\r\n".
"Reply-to: <%s>\r\n".
"Subject: %s\r\n".
"X-Mailer: webmailer\r\n".
"MIME-Version: 1.0\r\n".
"Content-Type: multipart/mixed;\r\n\tboundary=\"%s\"\r\n\r\n",
$from_name,
$from,
$from,
$title,
$boundary
);
$body = sprintf(
"--%s\r\n".
"%s\r\n".
"Content-Transfer-Encoding: base64\r\n".
"Content-Disposition: inline\r\n\r\n".
"%s\r\n".
"--%s",
$boundary,
$contentType,
chunk_split(base64_encode(strip_tags($message))),
$boundary
);
// $ufile = @$_FILES['attach'];
// if( is_array($ufile) ){
// foreach( $ufile['tmp_name'] as $key=>$val )
// {
// if( empty($ufile['tmp_name'][$key]) ) continue;
//
// $ftype = $ufile['type'][$key];
// $fname = $ufile['name'][$key];
//
// $fp = fopen($ufile['tmp_name'][$key],"r");
// $file = fread($fp, $ufile['size'][$key]);
// fclose($fp);
// @unlink($ufile['tmp_name'][$key]);
//
// $body .= sprintf(
// "\r\nContent-Type: %s; name=\"=?$charset?B?".base64_encode($fname)."?=\"\r\n".
// "Content-Transfer-Encoding: base64\r\n".
// "Content-Disposition: attachment; filename=\"=?$charset?B?".base64_encode($fname)."?=\"\r\n\r\n".
// "%s\r\n".
// "--%s",
// $ftype,
// chunk_split( base64_encode($file) ),
// $boundary
// );
// }
// }
$body .= "--";
return mail($recipient , $title, $body, $headers,"-f mailplug.co.kr");
}
또는
2)
function xmail($type,$to,$to_name,$from,$from_name,$title,$message,$charset="utf-8")
{
global $_FILES;
if($type!='html'){
$message = nl2br($message);
$contentType = "Content-Type: text/plain; charset=\"$charset\"; format=flowed";
}else{
$contentType = "Content-Type: text/html; charset=\"$charset\"";
}
$boundary = '----='.uniqid(rand(),true);
$title = "=?$charset?B?".base64_encode($title)."?=";
$from_name = "=?$charset?B?".base64_encode($from_name)."?=";
$to_name = "=?$charset?B?".base64_encode($to_name)."?=";
$recipient = sprintf("%s <%s>", $to_name, $to);
$headers = sprintf(
"From: %s <%s>\r\n".
"Reply-to: <%s>\r\n".
"Subject: %s\r\n".
"X-Mailer: webmailer\r\n".
"MIME-Version: 1.0\r\n".
"Content-Type: text/html;\r\n\tboundary=\"%s\"\r\n\r\n",
$from_name,
$from,
$from,
$title,
$boundary
);
return mail($recipient , $title, $message, $headers,"-f mailplug.co.kr");
}
$mail = $_POST['email'];
$sec = $_GET['sec'];
//$tit = iconv('utf-8','euc-kr',$_POST["subject"]);
$tit = "제목";
$text = "내용";
$tmp = explode("@",$mail);
$receiver_email = $mail; //받는 사람
$receiver = $tmp[0];
$email = 'admin@mailplug.co.kr';
$name ='LS IS [발신전용]';
$vl = xmail('html',$receiver_email,$receiver,$email,$name,$tit,$text);
if($vl==1){
echo "1";
}else{
echo "0";
}
'php' 카테고리의 다른 글
허프만 php 문자 압축 소스 HUFFMAN CODING WITH PHP AND JAVASCRIPT (0) | 2017.02.01 |
---|---|
PHP 세션 유지 ( session timeout ) 설정 (0) | 2017.01.26 |
strlen, strpos, strimwidth, substr, mb_strimwidth 길이 문제 (0) | 2016.11.16 |
[PHP] JSON 방식으로 Ajax 구현하기 (0) | 2016.06.23 |
html 테이블 자동줄바꿈 (0) | 2016.02.29 |