当域名由 Media Temple 托管且电子邮件由domains.live.com 托管时,使用 PHP 发送电子邮件

发布于 2024-12-09 13:17:07 字数 1137 浏览 0 评论 0原文

我在我的网站上设置了一个简单的表单来测试使用 PHP 发送电子邮件。

该表单将三个文本字段的输入发布到 email-form-process.php,如下所示:

<?php

    $email = $_POST['email'];

    $subject = "Test Email Worked";

    $msg = $_POST['comment'];

    mail ('$email','$subject','$msg');

    header('Location: email-form-confirm.php');
    exit();

?>

我在测试中回显了三个输入,以确保 email-form-process.php 正在从表单接收它们,这这是。

我遇到的问题是我的任何电子邮件都没有收到该电子邮件。我已经测试了它到@live.com 电子邮件和由domains.live.com 托管的两个自定义域。

我使用domains.live.com 来托管我网站的所有电子邮件。我通过我的主机 MediaTemple 设置了 DNS 记录,以便domains.live.com 处理我的电子邮件。这对于常规电子邮件内容非常有用,但我不确定使用由domains.live.com 托管的自定义域电子邮件以 PHP 发送电子邮件的最佳方法是什么。

如何通过 PHP 从 [email protected] 发送电子邮件我的域名由 MediaTemple 托管,我的电子邮件由domains.live.com 托管?

我尚未尝试使用 SMTP 方法。在以下链接中找到的解决方案对我来说是一个好的方向吗? http://www.9lessons.info/2009 /10/send-mail-using-smtp-and-php.html

预先感谢您提供的任何帮助!

-标记

I have setup a simple form on my website to test sending email using PHP.

The form posts the input of three text fields to email-form-process.php, which looks like this:

<?php

    $email = $_POST['email'];

    $subject = "Test Email Worked";

    $msg = $_POST['comment'];

    mail ('$email','$subject','$msg');

    header('Location: email-form-confirm.php');
    exit();

?>

I echoed out the three inputs in a test to make sure email-form-process.php is receiving them from the form, which it is.

The problem I am having is that the email isn't being received at any of my emails. I have tested it going to a @live.com email and to two custom domains hosted by domains.live.com.

I use domains.live.com to host all of my email for my websites. I have my DNS records setup via my host, MediaTemple, for domains.live.com to handle my email. This works really great for regular email stuff, but I'm not sure what the best way is to send email in PHP using my custom domain emails hosted by domains.live.com.

How do I send email from [email protected] via PHP when my domain is hosted by MediaTemple and my email is hosted by domains.live.com?

I have not tried using the SMTP method yet. Would the solution found at the following link be a good direction for me to go? http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html

Thank you in advance for any help you can offer!

-Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾听心声的旋律 2024-12-16 13:17:07

如果您在其他地方托管邮件,则需要禁用服务器的本地邮件。

http:// /kb.mediatemple.net/questions/519/How+to+enable+or+disable+local+mail+for+your+server%3F

If you're hosting mail elsewhere, you'll need to disable local mail for your server.

http://kb.mediatemple.net/questions/519/How+to+enable+or+disable+local+mail+for+your+server%3F

找个人就嫁了吧 2024-12-16 13:17:07

由于 Live 托管您的电子邮件,因此它可能会立即阻止/将传入电子邮件发送到垃圾邮件文件夹。您的网络服务器的 IP 与 live 的电子邮件服务器不同,因此它可能认为自己正在发送虚假电子邮件。

您可能还想研究一下 sendgrid;他们将您的服务器 IP 列入白名单,您的电子邮件肯定会通过。

希望这有帮助!

Because Live is hosting your email, it may be blocking/sending the incoming emails immediately to spam folder. Your web server has a different IP than live's email server, so it might think it is sending bogus emails.

You might also want to look into sendgrid; they put your server IP on a whitelist and your emails will DEFINITELY get through.

Hope this helps!

清君侧 2024-12-16 13:17:07

您可以使用 PHPMailer 之类的工具,这将使使用 SMTP 邮件变得更加容易。无论如何,这绝对是一个比使用 PHP 中内置的邮件命令更好的解决方案,因为 PHPMailer 为您提供了更好的附件处理、收件人处理等,而无需编写自己的标头来通过邮件功能发送。

您还可以从 MediaTemple 的服务器发送,并将主机名设置为您的域。它不必与 MX 记录匹配,尽管垃圾邮件过滤器会注意到这一点,因此您至少需要为您的域配置 SenderID 和 SPF,以便 MediaTemple 主机被视为您的域的有效电子邮件发件人。

You can use something like PHPMailer which will make it a LOT easier to use SMTP mail. That is definitely a better solution overall anyway than using the built in mail command in PHP as PHPMailer gives you much better attachment handling, recipient handling, etc. without having to write your own headers to send through the mail function.

You could also send from MediaTemple's server and just set the host name as your domain. It doesn't have to match the MX record although spam filters take notice of that and so you'll need to configure your domain for SenderID and SPF at the minimum so that the MediaTemple host is seen as a valid email sender for your domain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文