Jump to content

PHP on Mac: can send mail but cannot receive it.


marus

Recommended Posts

I am currently a newbie in PHP field. I am using Leopard at the moment and I am trying to send out emails with PHP. When I use the mail() function, the script seems to let me send out the mails but for some reasons I cannot receive them at all. Can someone help me out with this problem? Thanks a lot!

Thats the script I try to follow from a book.

 

<?php

if (!$_POST) {

echo "<html>

<head>

<title>Send an email</title>

</head>

<body>

<h1>Send a Newsletter</h1>

<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">

<p><strong>Subject:</strong><br/>

<input type=\"text\" name=\"subject\" size=\"30\"></p>

<p><strong>Mail Body:</strong><br/>

<textarea name=\"message\" cols=\"50\" rows=\"10\" wrap=\"virtual\"></textarea>

<p><input type=\"submit\" name=\"submit\" value=\"Send It\"></p>

</form>

</body>

</html>";

} else if ($_POST) {

if (($_POST["subject"] =="") || ($_POST["message"]=='')) {

header("Location: sendmymail.php");

exit;

}

 

$mysqli= mysqli_connect("localhost", "abc", "something", "datab");

 

if(mysqli_connect_errno()) {

printf("Connect failed: %s\n", mysqli_connect_error());

exit();

} else {

$sql = "SELECT email FROM subscribers";

$result= mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli));

 

$mailheaders ="From: Your Mailing List <[email protected]>";

 

while($row =mysqli_fetch_array($result)) {

set_time_limit(0);

$email= $row["email"];

mail("$email", stripslashes($_POST["subject"]), stripslashes($_POST["message"]),

$mailheaders);

echo "newsletter sent to: ".$email."<br/>";

}

mysqli_free_result($result);

mysqli_close($mysqli);

}

}

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.