Mail() not working

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
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Mail() not working

Post by Zeceer »

Hello,

suddently the mail() function stopped working at my web hotel. The mail doesn't get sent. Theres not any errors or anything. I just can't receive the e-mail :( .

Code: Select all

<?php

include("config.php");

session_start();

$to = "webshop@diett-kost.no";
$subject = "Webshop Bestilling";
$headers = "webshop@diett-kost.no";

//Cart

$cart = "";

foreach( $HTTP_SESSION_VARS&#1111;'items'] as $key=>$value )
&#123;
    $link = mysql_connect( $hostname, $username, $password );

    mysql_select_db( $db )
                 or die ( "Couldn't open $db: ".mysql_error() );

    $result = mysql_query( "SELECT * FROM products WHERE prodnr='".$key."'" );
    $row = mysql_fetch_assoc($result);

    $cartloop = '
    <table width="100%" height="20" border="0" cellpadding="1" cellspacing="0">
    <tr>

    <td width="20%" valign="top">'.$row&#1111;"prodnr"].'</td>
    <td width="40%" valign="top">'.$row&#1111;"product"].'</td>
    <td width="20%" valign="top">'.$row&#1111;"price"].',-'.'</td>
    <td width="20%" valign="top">'.$value.'</td>

    </tr></table>';
    
    mysql_close( $link );

    $cart = $cart.$cartloop;
&#125;

//The mail

$body = '
Fornavn: '.$_POST&#1111;'firstname'].'
<br>
Etternavn: '.$_POST&#1111;'lastname'].'
<br>
<br>
Adresse: '.$_POST&#1111;'adress'].'
<br>
Postnummer: '.$_POST&#1111;'postnumber'].'
<br>
Sted: '.$_POST&#1111;'place'].'
<br>
<br>
Telefon: '.$_POST&#1111;'phonenumber'].'
<br>
E-mail: '.$_POST&#1111;'email'].'
<br>
<br>
Kommentar: '.$_POST&#1111;'comment'].'
<br>
<br>
<b>Bestilling:</b><br><br>
<table width="100%" height="20" border="0" cellpadding="1" cellspacing="0" bgcolor="#f1f1f1">
<tr>
<td width="20%">Prodnr</td>
<td width="40%">Produkt</td>
<td width="20%">Pris</td>
<td width="20%">Antall</td>'."$cart";

mail($to,$subject,$body,"Content-type: text/html; charset=iso-8859-1\r\n");

session_destroy();

header( "Location: index.php" );

?>
Is there any way of making this work in another way? There may have been done some updates on the servers so that the function does not work anymore?
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Mail() not working

Post by TheBentinel.com »

Zeceer wrote:suddently the mail() function stopped working at my web hotel. The mail doesn't get sent. Theres not any errors or anything. I just can't receive the e-mail :( .
Sorry for the dumb question, but have you tried sending mail to some other account? Maybe that account is getting backed up? Can you fire the mailq command to see if the system has mail in its queue that it hasn't sent yet?

It wouldn't hurt to capture the output of the mail command and echo it. I think it returns a message of some sort, maybe a number.
Post Reply