phpinfo() shows jenn as the SMTP value. How weird is that?
Should I scrap PostCast and try JAMES?
Setting SMTP?
Moderator: General Moderators
Is it possible to send mails from within PHP-scripts without running an SMTP server on localhost.
My default SMTP-server is mail.planetinternet.be, but I'm not able to send emails from PHP-scripts.
this last one contains:
can somebody help me out here?
My default SMTP-server is mail.planetinternet.be, but I'm not able to send emails from PHP-scripts.
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>-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
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?
Digging through the help, I found a note from a user that built his own mail sending function that looks like it would do what you need. I haven't tested it, but I'll paste it here:
grey at greywyvern dot com (09-May-2003 04:23)
Here's a function I'm continually working at to send multiple emails while only opening the socket once (much faster than mail()) while sending a separate email to each address. It also includes many headers which you can adjust to your liking. Note the comment which explains the array format for incoming "To:" addresses.
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);
}
?>-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Ah, Windows.peoples wrote:thx m8, but I am running my Apache on Win2k
It looks like you can set your SMTP server in php.ini. It looks as if it is set to "localhost" by default, but you could change it to "mail.planetinternet.be".
Will it work? I really haven't a clue. I'm just digging around in the help. You might find this section helpful:
http://www.php.net/manual/en/ref.mail.php
Sorry I can't be more help.
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.