marus Posted January 5, 2008 Share Posted January 5, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/ Share on other sites More sharing options...
Northern Flame Posted January 5, 2008 Share Posted January 5, 2008 post your script Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-430985 Share on other sites More sharing options...
marus Posted January 5, 2008 Author Share Posted January 5, 2008 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); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-430987 Share on other sites More sharing options...
Northern Flame Posted January 5, 2008 Share Posted January 5, 2008 oh wait, are you running this script off your computer? or is the script uploaded on a website? Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-430990 Share on other sites More sharing options...
marus Posted January 5, 2008 Author Share Posted January 5, 2008 off a computer but if my mac's web sharing is on, isnt that I can send out emails as well? I am very new to this, I am sorry for any dumb questions. Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-430994 Share on other sites More sharing options...
Northern Flame Posted January 5, 2008 Share Posted January 5, 2008 well i dont know about web sharing but to the best of my knowledge you cant send emails via PHP from a computer, i may be wrong, does anybody else know?.... Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-430998 Share on other sites More sharing options...
revraz Posted January 5, 2008 Share Posted January 5, 2008 You would need to install a webserver with SMTP along with PHP, not sure if you can find that for a MAC or not. Google it. Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-431000 Share on other sites More sharing options...
marus Posted January 5, 2008 Author Share Posted January 5, 2008 Alright, I will give it a try then. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/84577-php-on-mac-can-send-mail-but-cannot-receive-it/#findComment-431004 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.