나는 php mail()을 통해 전자 메일을 보내고 있습니다. 그 안에는 간단한 (텍스트) 메일을받을 수 있습니다. 첨부 파일을 첨부 할 때 전자 메일에 첨부 파일을 받고 있지만 볼 때 파일은 항상 비어 있습니다. PDF 형식 일 때도 마찬가지입니다. 제발 도와주세요. 내 메일 발신 페이지의 코드는 다음과 같습니다첨부 파일을 볼 수 없습니다.
include_once("db_connect.php");
session_start();
error_reporting(16);
require_once('class.phpmailer.php');//Getting values from Session
$tot = $_SESSION['$tot'];
$from = $_SESSION['from'];
$message = $_SESSION['message'];
$subject = $_SESSION['subject'];
$full_nm = $_SESSION['firstnm']." ".$_SESSION['lastnm'];
$temp_passwd = $_SESSION['e_pwd'];
$email_use = $_SESSION['email'];
function send_mail($to, $message, $subject, $from, $temp_passwd, $full_nm, $email_use)
{
$message_org = nl2br($message);
$mail = new PHPMailer();
$body = $message_org;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->AddAttachment("Uploads/file.pdf");
$mail->ContentType = "mutlipart/alternative";
$mail->Host = "smtp.mail.yahoo.com";
$mail->Port = 465;
$mail->Username = $from;
$mail->Password = $temp_passwd;
$mail->SetFrom($from, $full_nm);
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $address);
if(!$mail->Send())
{
$err_send = "Mailer Error: " . $mail->ErrorInfo;
}
else
{
$err_send = "";
}
}
foreach($tot as $to_trim)
{
$to = trim($to_trim);
send_mail($to, $message, $subject, $from, $temp_passwd, $full_nm, $email_use);
echo $err_send;
}
The function AddAttachment in class.phpmailer.php is as follows:
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
try {
if ([email protected]_file($path)) {
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => 0
);
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
if ($e->getCode() == self::STOP_CRITICAL) {
return false;
}
}
return true;
}
서식을 수정하는 편집을 제출 하겠지만 코드 서식 지정 방법에 대한 도움말을 읽어야합니다.
을 여기 저기에 추가하면 특히 일관성이 없을 때 어려워집니다. – jedwards
@jedwards : 수정했습니다. 갑자기 편집 권한을 잃었습니다. http://pastebin.com/CTVRdwhm – nyson
리뷰를 업데이트해야 업데이트되었습니다. – jedwards