简体   繁体   English

PHP邮件未显示在电子邮件中

[英]PHP mail not showing up on email

I have created a small script that sends a multipart email via php the mail() (that has been a challenge in itself!). 我创建了一个小脚本,该脚本通过php通过mail()发送多部分电子邮件(这本身就是一个挑战!)。

When I test the script and send and email it all works fine, but when I try another address (one which has the same domain as the server) the email appears blank. 当我测试脚本并发送并通过电子邮件发送时,一切正常,但是当我尝试其他地址(与服务器具有相同域的地址)时,电子邮件将显示为空白。 All the content is there when you look at the raw code, but nothing displays. 当您查看原始代码时,所有内容均已存在,但没有任何显示。

I solved the problem by removing the doctype tag from the code and left everything bare coded. 我通过从代码中删除doctype标记解决了问题,并保留了所有未编码的内容。

I also noticed the php variable 我也注意到php变量

$body=' (html code here) '

The whitespace after ' was causing the email to show up empty sometime... I'm not exactly sure why! '之后的空格导致电子邮件有时显示为空白...我不确定为什么!

I have encountered a similar issue and it was because I had a website www.example.com sending an email to me@example.com but the web server and email servers were on different machines. 我遇到了类似的问题,这是因为我有一个网站www.example.com,将电子邮件发送到me@example.com,但是Web服务器和电子邮件服务器位于不同的计算机上。 I had to ask the host to sort it so that the website wouldn't try to route emails within the server itself. 我不得不要求主机对其进行排序,以使网站不会尝试在服务器内部路由电子邮件。

I managed to sort this by changing my own code to instead using something a little more supported - phpMailer . 我设法通过将自己的代码更改为使用更多受支持的东西-phpMailer来对此进行排序。

I found this very easy to use and install into my own code. 我发现这非常易于使用,并安装到我自己的代码中。 Also giving me as much flexibility as I had with my original code. 还给了我与原始代码一样多的灵活性。

I guess though this isn't sorting the original problem, but it did seem to sort on my code. 我想这虽然不是对原始问题的排序,但似乎确实对我的代码进行了排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM