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!

Link to comment
Share on other sites

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 <you@yourdomain.com>";

 

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);

}

}

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.