与godaddy的php邮件问题

时间:2012-03-08 18:51:32

标签: php email

Okkkk ...我对PHP邮件功能了解不多,所以不要因此而爆炸。问题是这个...我正在使用freedns.afraid.org名称服务器托管我自己的网站,当你进入我的域时,它会重定向到我的no-ip域。我主持使用xampp。我的域名在godaddy和我的电子邮件下注册。以下是我从配置到代码的所有设置。由于我不知道的原因,我无法发送电子邮件!我可能把这整件事搞砸了,但我只是在寻求帮助。

的php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = relay-hosting.secureserver.net
; http://php.net/smtp-port
smtp_port = 3535

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = account@godaddydomain.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

我的sendmail配置

[sendmail]

smtp_server=relay-hosting.secureserver.net
smtp_port=3535
error_logfile=error.log
debug_logfile=debug.log
auth_username=
auth_password=
force_sender=

我的html和php测试电子邮件代码

<html>
<head><title>PHP Mail() test</title></head>
<body>
This form will attempt to send a test email. Please enter where this test should be sent to<br><p>
<form action = "mail.php" method = "post" name="sendmail">
Enter an email address: <input type = "text" name = "to"><br>
<input type="submit" value="Send" name="submit"><input type="reset" value="Reset" name="reset"><br><p>
<?php
if(isset($_POST['to'])) {
       $mail_to=$_POST['to'];
    $mail_subject="Test email from";
    $mail_body="This is a test email, sent from ";
    $header = "<admin@godaddydomain.com>";

    if(mail($mail_to, $mail_subject, $mail_body,$header,"-fadmin@godaddyadmin.com")) {
        print "Email sent successfully!";
    } else {
        print "Email did not send!!!!!";
    }
}
?>
</body>
</html>

调试信息

12/03/08 11:08:42 ** This is a test email, sent from 
12/03/08 11:08:42 ** --- MESSAGE END ---
12/03/08 11:08:42 ** Connecting to relay-hosting.secureserver.net:3535
12/03/08 11:08:52 ** Disconnected.
12/03/08 11:08:52 ** Disconnected.
12/03/08 11:08:52 ** Disconnected.
12/03/08 11:08:52 ** Disconnected.
12/03/08 11:08:52 ** Connect timed out.
12/03/08 11:29:18 ** --- MESSAGE BEGIN ---
12/03/08 11:29:18 ** To: bice64g@aim.com

我也收到此错误

  

警告:mail()[function.mail]:无法连接到mailserver   “relay-hosting.secureserver.net”端口3535,验证您的“SMTP”和   php.ini中的“smtp_port”设置或者使用ini_set()   第20行的C:\ xampp \ htdocs \ Test \ mail.php

12/03/08 11:29:18 ** Subject: Test email from
12/03/08 11:29:18 ** Content-type: text/html
12/03/08 11:29:18 ** From: "PHP mail() Test Script"<noreply@>
12/03/08 11:29:18 ** 
12/03/08 11:29:18 ** This is a test email, sent from 
12/03/08 11:29:19 ** --- MESSAGE END ---
12/03/08 11:29:19 ** Connecting to relay-hosting.secureserver.net:3535
12/03/08 11:29:29 ** Disconnected.
12/03/08 11:29:29 ** Disconnected.
12/03/08 11:29:29 ** Disconnected.
12/03/08 11:29:29 ** Disconnected.
12/03/08 11:29:29 ** Connect timed out.

2 个答案:

答案 0 :(得分:1)

您提供的错误表明您正在尝试将“relay-hosting.secureserver.net”用作应用程序中的中继服务器。该地址是离开Go Daddy虚拟主机服务器的电子邮件的网关。它不能从Go Daddy Dedicated服务器或不在Go Daddy数据中心内的个人服务器上获得。如果您在Go Daddy Virtual或Dedicated服务器上托管此服务器,您可以从Go Daddy支持聊天中获取您的个人中继服务器信息。如果您在Go Daddy网络之外托管此应用程序,则需要从您的托管或网络提供商处获取正确的中继信息。希望这会有所帮助。

答案 1 :(得分:0)

您应该注释sendmail_path ...这是来自帮助http://uk.php.net/manual/en/mail.configuration.php#ini.sendmail-path

  

此指令也适用于Windows。如果设置,smtp,smtp_port和   将忽略sendmail_from并执行指定的命令。

同时检查debug.log - 那里应该有一些指示......

你的标题

$header = "<admin@godaddydomain.com>";

无效,尝试类似:

$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com';