Jump to content

Mailing error?


firecat318

Recommended Posts

I have this code to send a sample message to an email:

 

<?php
$to = "firecat318@gmail.com";
$subject = "hello";
$message = "this is just a random test";

$mail = mail($to, $subject, $message);

if(!$mail) {
die("There was a problem when mailing!");
} else {
echo "Thank you for sending your mail!";
}

?>

 

When I run the script, it says there was an error mailing.

 

Is there anything in particular that I need to set up on my host so that it allows me to send mails?

Link to comment
Share on other sites

I'm very quite stumped.  Is there something special that I need to setup in my hosting that will allow me to send emails, or will it work without anything special setup?  I'm using godaddy windows hosting.  I've tried lots of different variations of this code but it won't work.  I'm just wondering if there is something I'm not getting that is causing the mail not to be sent. 

Link to comment
Share on other sites

*Cough* Switch to Linux because Windows sucks *Cough*

 

I did a Google search for "php mail windows godaddy" and got this *sigh*:

You need to use PEAR Mail for it to work.  Here's an example.

 

require_once "Mail.php";

 

function emailHtml($from, $subject, $message, $to) {

$host = "localhost";

$username = "";

$password = "";

 

$headers = array ('MIME-Version' => "1.0", 'Content-type' => "text/html; charset=iso-8859-1;", 'From' => $from, 'To' => $to, 'Subject' => $subject);

 

$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => false));

 

$mail = $smtp->send($to, $headers, $message);

if (PEAR::isError($mail))

return 0;

else

return 1;

}

 

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.