Posted: Mon Mar 08, 2004 3:12 pm
phpinfo() shows jenn as the SMTP value. How weird is that?
Should I scrap PostCast and try JAMES?
Should I scrap PostCast and try JAMES?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
http://peoples.dyndns.org/phpinfo.phpCode: Select all
http://peoples.dyndns.org/extra/mailtest.phpCode: Select all
<html><head><title>PHP Mail Tester</title></head>
<body>
<?php
if ($address=="") {
echo "<form action="mailtest.php" method=get><p>Address to email: <input type=text name=address></p>";
echo "<p><input type=submit value="Send email"></p>";
} else {
$subject = "Testing mail() function";
$message = "This is a test email";
mail($address,$subject,$message,"From: "Mail Test" <$address>");
echo "<p>Mail sent. Were any errors shown? If there were, mail is probably not set up correctly.</p>";
}
?>
</body>
</html>I get the impression that you can't, unless you're running it on Windows. Under Linux, PHP drops out and runs 'sendmail' to send your mail.peoples wrote:Is it possible to send mails from within PHP-scripts without running an SMTP server on localhost?
Code: Select all
<?php
function socketmail($toArray, $subject, $message) {
// $toArray format --> array("Name1" => "address1", "Name2" => "address2", ...)
ini_set(sendmail_from, "myemail@address.com");
$connect = fsockopen (ini_get("SMTP"), ini_get("smtp_port"), $errno, $errstr, 30) or die("Could not talk to the sendmail server!");
$rcv = fgets($connect, 1024);
fputs($connect, "HELO {$_SERVER['SERVER_NAME']}\r\n");
$rcv = fgets($connect, 1024);
while (list($toKey, $toValue) = each($toArray)) {
fputs($connect, "MAIL FROM:myemail@address.com\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RCPT TO:$toValue\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "DATA\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "Subject: $subject\r\n");
fputs($connect, "From: My Name <myemail@address.com>\r\n");
fputs($connect, "To: $toKey <$toValue>\r\n");
fputs($connect, "X-Sender: <myemail@address.com>\r\n");
fputs($connect, "Return-Path: <myemail@address.com>\r\n");
fputs($connect, "Errors-To: <myemail@address.com>\r\n");
fputs($connect, "X-Mailer: PHP\r\n");
fputs($connect, "X-Priority: 3\r\n");
fputs($connect, "Content-Type: text/plain; charset=iso-8859-1\r\n");
fputs($connect, "\r\n");
fputs($connect, stripslashes($message)." \r\n");
fputs($connect, ".\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RSET\r\n");
$rcv = fgets($connect, 1024);
}
fputs ($connect, "QUIT\r\n");
$rcv = fgets ($connect, 1024);
fclose($connect);
ini_restore(sendmail_from);
}
?>Ah, Windows.peoples wrote:thx m8, but I am running my Apache on Win2k
Congrats on being the 10,000th user to register on this forum!peoples wrote:thx m8, but I am running my Apache on Win2k and the mail function does not work with my default SMTP-server.
How can I run my own SMTP-server to make the mailing work.
Please not to difficult 'cause I'm just a newbie at this all.