Page 1 of 1

Sending email

Posted: Tue Oct 11, 2005 12:40 pm
by greatFade
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I know that PHP makes sending emails very easy, but for some reason when I try to use code that sends an email the page freezes when loading. I'm currently testing the php code on my localhost, and I'm using Apache. I was wondering if this setup doesn't allow sending email or if there is a way to set it up for sending email. BTW - if it makes any difference, here is the code I'm using:

Code: Select all

<?php

$to = "nastybuttr@hotmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$header = 'From: nastybuttr@hotmail.com';

if (mail($to, $subject, $body, $header))
{
   echo("<p>Message successfully sent!</p>");
}
else
{
   echo("<p>Message delivery failed...</p>");
}

?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Oct 11, 2005 12:55 pm
by feyd
you probably don't have a mail server on your localhost, the mail() function is horrendously slow and as such, many here (including me) recommend using phpMailer instead.