电话号码未来gmail收件箱。 它在发送时显示一些错误消息(第84行的警告:sendemail()缺少参数5,第61行定义)。使用来自github的Phmamailer文件夹。 尝试了许多没有解决方案的东西。
<?php
$msg = "";
if (isset($_POST['submit'])) {
require 'phpmailer/PHPMailerAutoload.php';
function sendemail($to, $from, $fromName, $body, $phone, $attachment = "")// line 61 {
$mail = new PHPMailer();
$mail->setFrom($from, $fromName);
$mail->addAddress($to);
$mail->addAttachment($attachment);
$mail->Phone = ($phone);// argument 5
$mail->Subject = 'Naukriglobal.com - Email- Resume';
$mail->Body = $body;
$mail->isHTML(false);
return $mail->send();
}
$name = $_POST['username'];
$email = $_POST['email'];
$body = $_POST['body'];
$phone = $_POST['phone'];
$file = "attachment/" . basename($_FILES['attachment']['name']);
if (move_uploaded_file($_FILES['attachment']['tmp_name'], $file)) {
if (sendemail('hameed.basha278@gmail.com', $email, $name, $body, $phone, $file)) {
$msg = 'Email sent!';
sendemail('hamidsince1990@gmail.com', 'NEW', 'RESUME', 'hey, we have received new email');//line84
} else
$msg = 'Email failed!';
} else
$msg = "Please check your attachment!";
}
?>
<form method="post" action="index.php" enctype="multipart/form-data">
<input class="name1" type="text" name="username" placeholder="Name..." required><br>
<input class="email1" type="email" name="email" placeholder="Email..." required><br>
<textarea class="text1" name="body" placeholder="Message..." required></textarea><br>
<input type="text" name="phone" maxlength="15" placeholder="phonenumber" required="true" class="tel-number-field long" />
<h3 class="h3">Upload Resume </h3>
<input class="fileattach" type="file" placeholder="upload resume" name="attachment" required><br></input>
<input class="submit1" type="submit" name="submit" value="Send Email">
</form>
答案 0 :(得分:0)
$phone
是sendmail
函数的必需参数。您需要为其提供值。
使用与$_POST
键关联的phone
值进行设置。这可能存在也可能不存在。使用isset
功能检查是否设置了值。
然后你有几个选择:
1.如果{i}未设置,则提供$phone
的默认值
$DEFAULT_PHONE = "800-555-1212";
...
$phone = $DEFAULT_PHONE
if (isset($_POST['phone'])) {
$phone = $_POST['phone'];
}
2.如果未设置$phone
,则不传递值,并提供默认值作为函数的一部分
function sendemail($to, $from, $fromName, $body, $attachment = "", $phone = "800-555-1212")
...
if (!isset($_POST['phone'])) {
if (sendemail('hameed.basha278@gmail.com', $email, $name, $body, $file)){
...
}
...
} else
if (sendemail('hameed.basha278@gmail.com', $email, $name, $body, $file, $phone)){
...
}
...
}
3.确保发布到此页面的值始终为$_POST['phone']
也就是说,在此之前更改页面上的表单验证,以强制用户必须使用$_POST['phone']
上的required
属性为input
提供值:< / p>
<input type='tel' name='phone' id='phone' required />
答案 1 :(得分:0)
1。)在您function sendemail
开始{
的代码中,我们会对您的代码进行评论,希望您的代码正确无误。
2.。)将手机输入线更改为下方,然后重试
<input type="tel" name="phone"> placeholder="phonenumber" required><br>