douhunkuang8955 2018-08-09 16:01
浏览 79

PHP Sender电子邮件地址作为电子邮件标题

When we receive messages through our site, the 'sender' of the email is listed as "newwavea@host424.hostmonster.com", rather than the address of the person who submitted a message. Could you check my PHP and see where I've gone wrong? Thanks. Here's the WEBPAGE LINK

<?php

if(!empty($_POST['full-name1']) or !empty($_POST['email1']) ) {
    header('Location: success.html');
}

$name = $_POST['full-name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: SSR'; 
$to = 'info@new-wave-academy.com'; // send to this address
$subject = $_POST['subject'];

$body = "From: $name

Email: $email
 
Message:
 $message";

mail($to, $subject, $body); 
header("Location: http://new-wave-academy.com/Contact/success.html"); /* Redirect browser */
exit();
?>
  • 写回答

1条回答 默认 最新

  • dos49618 2018-08-09 16:13
    关注

    From and Return-path addresses must be set explicitly. PHP will not parse the message body looking for them (why should it?). Since you aren't setting any, the system will simply use default value set in server config.

    You can use the $additional_headers parameter for sender and, in many numbers, you can use $additional_parameters for the return address:

    bool mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] )

    (reference)

    Beware though that the underlying mail transport service may or may not allow arbitrary addresses in these fields.

    It's also very easy to screw the message format with mail() so I strongly recommend a third party library like Swift Mailer or PHPMailer.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算