检索包含日期和时间的电子邮件


retrieving email with date and time

我有一个小表单,由于某种原因,只要一个小问题,一切都很好。当您收到来自表单的电子邮件时,日期不会显示在发送的电子邮件中,而是显示在数据库中。。ip在电子邮件中显示没有问题。

$message = "Welcome'n'n'n'nThank you for registering, if you have received this email then you have successfully created your new account. This message was sent from an unmonitored account. Any responses will not be read.'n'nRequest made from: " . $ip = $_SERVER['REMOTE_ADDR'];
' on ' . $date = date('Y/m/d H:i:s');
$additional_headers = "From: $from'nReply-To: $from'nContent-Type: text/plain";
mail($to, $subject, $message, $additional_headers);

日期没有出现在电子邮件中的原因是特定的行没有连接到任何内容。

$message = "Welcome'n'n'n'nThank you for registering, if you have received this email then you have successfully created your new account. This message was sent from an unmonitored account. Any responses will not be read.'n'nRequest made from: " . $ip = $_SERVER['REMOTE_ADDR'];
        ' on ' . $date = date('Y/m/d H:i:s');

应该是:

$message = "Welcome'n'n'n'nThank you for registering, if you have received this email then you have successfully created your new account. This message was sent from an unmonitored account. Any responses will not be read.'n'nRequest made from: " . $ip = $_SERVER['REMOTE_ADDR'] . " on " . $date = date('Y/m/d H:i:s');

IP部分后面有一个分号,并且您的日期没有连接到字符串上。用假IP回声出你的$message变量当前返回的是:

欢迎感谢您注册,如果您收到此电子邮件那么您已经成功创建了新帐户。此消息是从不受监控的帐户发送。任何回复都不会被阅读。请求来自:0.0.0.0

根据我的代码建议,它返回:

欢迎感谢您注册,如果您收到此电子邮件那么您已经成功创建了新帐户。此消息是从不受监控的帐户发送。任何回复都不会被阅读。请求来自:0.0.0.0 2015年12月26日14:59:56

附言:我还把你的'字符末尾改成了",一致性提高了可读性。