PDA

View Full Version : mail() function Undefine in external host


Leinad
06-12-2003, 07:52 AM
To all PHP Guru,

I have a php script hosted in a webserver. and that script contains a mail function that sends email to whoever is in the database. However, when I tried to run that script, I have the following error:

Fatal error: Call to undefined function: mail()

Since this is an external host, I couldn't do anything to the php.ini file. so what are the alternate so that I can send emails?

Can I use an external smtp server? If so, I guess I have to use the username + password... do you guys have any example?

THanks!!

sleepingdanny
06-13-2003, 12:03 PM
Why don't you show me your code... :rolleyes:

Leinad
06-13-2003, 02:20 PM
To be simple, I removed the code that read the email from database, so it's simply posting back the data back to same function.


<html>
<head>
<title>Personalised Hello World</title>
</head>
<body>
<?php
// include("dbconnect.php");
if(!empty($HTTP_POST_VARS['name'])) {

$fromname = $HTTP_POST_VARS['name'];
$fromemail = $HTTP_POST_VARS['email'];


$mail_to = $HTTP_POST_VARS['toemail'];
$mail_subject = $HTTP_POST_VARS['subject'];
$mail_body = $HTTP_POST_VARS['message'];
$mail_body = str_replace("\r", "<br />", $mail_body);
$mail_body .= "<br /><table width=\"300\" border=\"1\" bgcolor=\"#AAAAAA\"><tr><td>This email is sent from xxx</td></tr></table>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $fromname <$fromemail>";

echo "Greeting, {$HTTP_POST_VARS['name']}, and welcome.";

if(mail($mail_to,$mail_subject,$mail_body,$headers)) {
$str = "<div class='subResult'>Thank you for your inquiry.";
$str .= " An email has been sent with your request, we will get in touch with you ASAP.</div>";
echo $str;
} else {
$str = "There was a problem sending the mail.";
$str .= " Please check that you <a href='java script: void(history.back());'>filled";
$str .= " in the form correctly</a>.";
echo $str;
}



} ?>
<form action="<? echo($_SERVER["PHP_SELF"]);?>" method="post">
Enter your name: <input type="text" name="name" /> and your email address: <input type="text" name="email" value="" /><br />
Send to:<input type="text" name="toemail" /></br>
subject:<input type="text" name="subject" /></br>
Message:<textarea name="message"></textarea>
<input type="submit" value="Send Mail"/>
<form>
<body>
</html>

zoobie
06-15-2003, 07:19 PM
Looks like they have the mail() disabled. :D
Yes...You could use a script @ hotscripts that sends SMTP...but your account will have to allow sending without popping first...which most don't. Those scripts are monsters...monsters...but you may be able to somehow trigger the pop before SMTP somehow...perhaps thru a cron job. Somehow, if your "host" doesn't have mail() enabled, I doubt if they have cron jobs. :)