Jump to content

Mailing error?


firecat318

Recommended Posts

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

 

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/104032-mailing-error/
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
https://forums.phpfreaks.com/topic/104032-mailing-error/#findComment-534025
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
https://forums.phpfreaks.com/topic/104032-mailing-error/#findComment-534040
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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