私は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