添付ファイル付きの電子メールをPHPで送信したいと思います。しかし、電子メールアドレスと添付ファイルが私のコードで正しく受信されない。メールアドレスを手動で渡すと正常にメールを送信できますが正常に受信終了に行くことはありません。電子メールアドレスを受信し、添付ファイルがphpmailerで正しく取得されない
<form action="sendemail.php" enctype="multipart/form-data" >
<h1 class="cta-title">Its a Call To Action</h1>
<div class="cta-desc">
<input type="text" value='<?= $row['catogary'];?>' readonly style="width: 75%"><br><br>
<input type="text" value='<?= $row['company_name'];?>' readonly style="width: 75%"><br><br>
<input type="text" value='<?= $row['location'];?>' readonly style="width: 75%"><br><br>
<input type="text" value='<?= $row['qulification'];?>' readonly style="width: 75%"><br><br>
<input type="text" value='<?= $row['catogary'];?>' readonly style="width: 75%"><br><br>
<input type="text" value='<?= $row['indate'];?>' readonly style="width: 37.5%">
<input type="text" value='<?= $row['expdate'];?>' readonly style="width: 37.5%">
<input type="text" value='<?= $row['email'];?>' ><br>
<input type="file" name="uploaded_file" id="uploaded_file" class="text-center center-block well well-sm">
<input type="submit" id="btn" name="btn" class="btn btn-primary" value="Apply">
</div>
</form>
sendemail.php
<?php
$email2=$_POST['email'];
require_once('PHPMailer/PHPMailerAutoload.php');
//PHPMailer Object
$mail = new PHPMailer;
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "uwucst14xxxx";
$mail->SetFrom("[email protected]");
$mail->FromName = "Internship Management";
//To address and name
$mail->addAddress($email2);
//$mail->addAddress("[email protected]"); //Recipient name is optional
//Address to which recipient will reply
$mail->addReplyTo("[email protected]", "Reply");
//CC and BCC
//$mail->addCC("CC");
//$mail->addCC("CC");
//$mail->addBCC("[email protected]");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = 'CV for internship Vacancy';
$mail->Body = "Attached";
//$mail->AltBody = "This is the plain text version of the email content";
//$mail->AddAttachment($target_path,$CV);
if (isset($_FILES['uploaded_file']) && $_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['uploaded_file']['tmp_name'],$_FILES['uploaded_file']['name']);
}
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
//echo 'Not sent: <pre>'.print_r(error_get_last(), true).'</pre>';
}
else
{
//echo "Message has been sent successfully";
echo 'Successfully Applied for vacancy';
}
//**end of send e-mail**
?>
エラーがある:あなたがこれはあなたのformタグである
<?php
$email2=$_POST['email'];
を使用しているsendemail.phpファイルで
Undefined index: email in /storage/h7/602/1448602/public_html/sendemail.php on line 2
あなたが問題になっていることは何ですかcing? –
ご迷惑をおかけして申し訳ございません –
あなたのフォームタグには属性がありませんメソッド= "投稿"とmysqlタグはこのコードまたは質問で使用されていないので削除してください –