dorisdong0514 2018-07-03 14:55
浏览 46

从@yahoo帐户以外的所有发件人接收的PHP联系表单

I have created a php contact form and for the most part it seems to work fine apart from when the sender is using a @yahoo email address. I have tested with hotmail and gmail addresses and all are being rceived OK.

I have used PHPMailer in order to try and avoid such problems but it still doesnt not seem to work.

Any help would be great and if you could provide example code that would be awesome!

as a side note - I am hosting the index.php file through godaddy (not sure if this could be causing an issue)

<?php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

$msg = "";

if (isset($_POST['submit'])) {
    require 'phpmailer/src/Exception.php';
    require 'phpmailer/src/PHPMailer.php';
    require 'phpmailer/src/SMTP.php';

    function sendemail ($to, $from, $body) {
        $mail = new PHPMailer(true);
        $mail->setFrom($from);
        $mail->addAddress($to);
        $mail->Subject = 'Contact Form - Email';
        $mail->Body = $body;
        $mail->IsHTML(false);

        return $mail->send();
    }

    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $body = $_POST['body'];

    if (sendemail('example@gmail.com', $email, $subject, $body)) {
        $msg = 'Email has been sent, thank you!';
    } else 
        $msg = 'Email failed, please try again later';       

    }

?>

<title>Test Contact Form Using PHPMailer</title>

<body>

    <div id="contactInnerWrapper">
        <a href="#"><span id="close">&times;</span></a>
        <h1 id="h1contactForm">Get in touch</h1>
            <form method="post" action="index.php">
                <label for="email">Email address:</label><br>
                <input  type="email" name="email"  placeholder="Enter email" id="email">
                <label for="subject">Subject:</label>
                <input  type="text" name="subject" id="subject"><br>
                <label for="body">What would you like to ask us?</label><br>
                <textarea  type="text" name="body" rows="7" id="content"></textarea>
                <button type="submit" name="submit" id="submit">Submit</button>
            </form>
            <br><br>
            <?php echo $msg; ?>
    </div>


</body>

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题