开发者

emailing with php

What's wrong with this...? I don't get an email back... Also, does the from address have to be a real address? If I run this on a computer that doesn't have Outlook Express, will it not work? How can I m开发者_如何学运维ake it work on computers like that?

<html>

<head>
<title>Test php</title>
</head>

<?php
$to = "asjjohnson127@aim.com";
$subject = "testing php emailing";
$from = "asjjohnson127@gmail.com";
$headers = "From: $from";
$message = "Your username is " . $_POST['username'];
if (mail($to,$subject,$message,$headers))
    echo "Mail Sent.";
else
    echo "Problem with mail.";
?>

<body>
</body>
</html>


If your running the script on a local server you'll need to configure the php.ini look for the following and change to your ISP's SMTP server.

[mail function]
SMTP = smtp.isp.net
sendmail_from = me@isp.net

You code will send email, its an issue with your SMTP configuration.

Another way to do it is set SMTP to localhost then use a SMTP service http://www.softstack.com/freesmtp.html usually runs on port 25 If I remember correctly.


You have to send mail from a machine that can be accessed directly from outside - via IP or URL. Having Outlook has absolutely nothing to do with that.


Outlook is an email client, you need to connect to an email server, the easy way is to buy a cheap hosting account as this replaces the option where you have to setup your own email server.(Some ISP block port 25 to prevent spam)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜