PHPMailer没有发送任何电子邮件,我可以';我没有发现问题

PHPMailer没有发送任何电子邮件,我可以';我没有发现问题,php,phpmailer,Php,Phpmailer,所以我用phpmailer做了一个联系表。 我知道我做的每件事都是对的。其他人可以通过某种方式发送电子邮件。我不使用表单(不提交)发送电子邮件,只需加载页面 但是我想把表格中的数据发送给我,但是它不适用于提交 这里是我的代码,通过加载页面的自动编译现在在一个评论中 <?php $msg = ""; if (isset($_POST['submit'])) { require 'phpmailer/PHPMailerAutoload.php'; function

所以我用phpmailer做了一个联系表。 我知道我做的每件事都是对的。其他人可以通过某种方式发送电子邮件。我不使用表单(不提交)发送电子邮件,只需加载页面

但是我想把表格中的数据发送给我,但是它不适用于提交

这里是我的代码,通过加载页面的自动编译现在在一个评论中

    <?php
$msg = "";

if (isset($_POST['submit'])) {
    require 'phpmailer/PHPMailerAutoload.php';

    function sendemail($to, $from, $fromName, $body, $attachment) {
        $mail = new PHPMailer();
        $mail->addAddress($to);
        $mail->setFrom($from, $fromName);
        $mail->Subject = "Test email!";
        $mail->isHTML(false);
        $mail->Body = $body;
        $mail->addAttachment($attachment);

        return $mail->send();
    }

    $name = $_POST['vorname'] + ' ' + $_POST['nachname'];
    $email = $_POST['email'];
    $body = $_POST['address'] + ', ' + $_POST['plz'] + ', ' + $_POST['ort'];

    $file = "attachment/" . basename($_FILES['attachment']['name']);

    if (move_uploaded_file($_FILES['attachment']['tmp_name'], $file)) {
        if (sendemail('tareq@thejami.com', $email, $name, $body, $file))
            $msg = "email sent";
        else
            $msg = "failed";
        } else
            $msg= "fail";
}
    /*
    //we need to create an instance of PHPMailer
    $mail = new PHPMailer();

    //set where we are sending email
    $mail->addAddress('tareq@thejami.com', 'testme');

    //set who is sending an email
    $mail->setFrom('myappkl@gmail.com', 'Admin at CPI');

    //set subject
    $mail->Subject = "Test email!";

    //type of email
    $mail->isHTML(true);

    //write email
    $mail->Body = "<p>this is our email body</p><br><br><a href='http://google.com'>Google</a>";

    //include attachment
    $mail->addAttachment('fbcover.png', 'Facebook cover.png');

    //send an email
    if (!$mail->send())
    echo "Something wrong happened!";
    else
    echo "Mail sent";
    */
?>

<html lang="de">
    <body>
        <form method="post" action="index.php" enctype="multipart/form-data" class="formular">
        <h2>Bestellformular</h2>
        Name:<span class="required">*</span><br>
        <input class="texte" style="width:170px;" required type="text" name="vorname" placeholder="Vorname"><input class="texte" style="width:170px;" required type="text" name="nachname" placeholder="Nachname"><br>
        Email:<span class="required">*</span><br>
        <input class="texte" required style="width:350px;" type="email" name="email" placeholder="Email"><br>
        Adresse:<span class="required">*</span><br>
        <input class="texte" required style="width:350px;" type="text" name="address" placeholder="Straße, HausNr."><br>
        <input class="texte" required style="width:170px;" type="number" name="plz" placeholder="PLZ"><input class="texte" required style="width:170px;" type="text" name="ort" placeholder="Ort"><br>
        Handy:<br>
        <input class="texte" style="width:350px;" type="number" name="nummer" placeholder="Handynummer <optional>"><br>
        Bild aussuchen:<span class="required">*</span><br>
        <input required class="texte" style="width:350px;" type="file" name="attachment"><br>
        <input class="button" style="width:350px;" type="submit" value="bestellen"><br>
        </form><br>
        <?php echo $msg; ?>
    </body>
</html>

最佳公式
姓名:*

电子邮件:*

地址:*


方便:

澳大利亚图片报:*




您正在检查
$\u POST['submit']
,但您的表单不包含它

要使其正常工作,您必须在提交按钮中添加
name=“submit”


您正在检查
$\u POST['submit']
,但您的表单不包含它

要使其正常工作,您必须在提交按钮中添加
name=“submit”


哦,我没注意到。谢谢你,我一直在寻找一些解决方案,直到现在大约3个小时。现在它确实起作用了,谢谢!哦,我没注意到。谢谢你,我一直在寻找一些解决方案,直到现在大约3个小时。现在它确实起作用了,谢谢!这不是问题的原因,而是您使用的是旧版本的PHPMailer;升级。这不是问题的原因,而是您使用的是旧版本的PHPMailer;升级