Sending email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
greatFade
Forum Newbie
Posts: 2
Joined: Tue Oct 11, 2005 12:36 pm

Sending email

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply