duanli0162 2015-08-09 13:34
浏览 26

电子邮件不在实时服务器上运行,但通过本地主机Xampp工作

Hey guys i am having this weird issue with sending information from my contact form to my email address. I have tested my code on local host through Xampp and i receive the emails perfectly fine, however when i uploaded the code to the server and submit. The success message shows as it should but no email is received, not even in the junk folder.

<?php
$name = $_POST['name1'];
$email = $_POST['email2'];
$message = $_POST['message3'];
$from = 'From: Testing';
$to = 'testing@hotmail.com';
$subject = 'Contact Form Testing';

$body = "From: $name
 Email: $email
 Message:
 $message";

if ($_POST['submit']){
    /*Do something when the submit has been pressed*/
    if (mail ($to, $subject, $body, $from)){
        $_SESSION['Success'] = '<div class="alert alert-success" role="alert">Your Message Has Been Sent!</div>';
        header('Location: index.php#fifthpage');
    } else{
        $_SESSION['Error'] = '<div class="alert alert-danger" role="alert">Something Went Wrong Please Try Again!</div>';
        header('Location: index.php#fifthpage');
    }
}

?>
  • 写回答

1条回答 默认 最新

  • dsa2c2255888 2015-08-09 13:52
    关注
        $to = 'testing@hotmail.com';
        $from = $_POST['email2'];
        $subject = 'Contact Form Testing';
        $body = $_POST['message3']."
    ";
        $headers = "From: $from
    Reply-to: $from";
        $sent = mail($to, $subject, $body, $headers);
    
    if($sent){
    echo "The message was sent";
    }
    else{
        echo "Sending failed";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?