PHP mail function, hvad gør jeg forkert?

Tags:    php mail

<< < 12 > >>
Hvad er der galt siden den ikke vil sende mine mails?

function kvittering($db,$page){
if( $_GET['page'] == 'kvittering') {

$first = @$_SESSION['c_info']['name'];
$last = @$_SESSION['c_info']['lastname'];
$adr = @$_SESSION['c_info']['adress'];
$sipcode = @$_SESSION['c_info']['sipcode'];
$city = @$_SESSION['c_info']['city'];
$mail = @$_SESSION['c_info']['email'];
$tlf = @$_SESSION['c_info']['tlf'];
$date = @$_SESSION['c_info']['datetime'];

if(!empty($_SESSION['c_info']['otheradress']) || !empty($_SESSION['c_info']['othersipcode']) || !empty($_SESSION['c_info']['othercity'])){

$otheradr = $_SESSION['c_info']['otheradress'];
$othersipcode = $_SESSION['c_info']['othersipcode'];
$othercity = $_SESSION['c_info']['othercity'];

$sql = "insert into e_orders(o_first,o_last,o_adr,o_sipcode,o_city,o_mail,o_tlf,o_status,o_a_adr,o_a_sipcode,o_a_city,o_date) value('".$first."','".$last."','".$adr."','".$sipcode."','".$city."','".$mail."','".$tlf."',1,'".$otheradr."','".$othersipcode."','".$othercity."','".$date."')";

}else{

$sql = "insert into e_orders(o_first,o_last,o_adr,o_sipcode,o_city,o_mail,o_tlf,o_status,o_date) value('".$first."','".$last."','".$adr."','".$sipcode."','".$city."','".$mail."','".$tlf."',1,'".$date."')";
};
mysqli_query($db,$sql) or die (mysqli_error($db));



$sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query);

// multiple recipients
$to = 'eksempel@ofir.dk' . ', '; // note the comma
$to .= $res["o_mail"];

// subject
$subject = 'Ordrebekræftelse eksempel.dk';

// message

$message = ''; // Selve beskeden til mailen opbygges i denne variable
$message .= '<table border="0" align="center" width="980px" cellspacing="15" >';
$message .= '<tr>';
$message .= '<td><strong>Tak for din bestilling:</strong></td>';
$message .= '</tr>';
$message .= '<tr>';
$message .= '<td colspan="2"><hr></td>';
$message .= '</tr>';
$message .= '<tr>';
$message .= '<td>Bestillingsdato:';

$sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query);
$message .= $res['o_date'];

$message .= '</td>';
$message .= '</tr>';
$message .= '<tr>';
$message .= '<td>';
$message .= $res['o_first'].$res['o_last']."<br />";
$message .= $res['o_adr'].'<br />'.$res['o_sipcode'].$res['o_city'].'<br />';
$message .= "E-mail: ".$res['o_mail']."<br />";
$message .= "Tlf.: ".$res['o_tlf']."";
$message .= '</td>';
$message .= '</tr>';
$message .= '<tr>';
$count = count(@$_SESSION['basket']['fisk_id']);
$message .= '<table width="980px" border="0" align="center" cellspacing="5">';
$message .= '<tr>';
$message .= '<td width="164" bgcolor="#77BBFF">Produkt: </td>';
$message .= '<td width="64" bgcolor="#77BBFF">Stk/Gram: </td>';
$message .= '<td width="164" bgcolor="#77BBFF">Pris:</td>';
$message .= '<td width="164" bgcolor="#77BBFF">Antal bestilte gram/fisk: </td>';
$message .= '<td width="164" bgcolor="#77BBFF" style="text-align:right;">SubTotal:</td>';
$message .= '</tr>';
$totalprice = 0;
for($i = 0; $i < $count;$i++){
$message .= "<tr>";
$message .= "<td style='text-align:left;' style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_art'][$i]."</td>";
$message .= "<td style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_gram'][$i]." </td>";
$message .= "<td style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['fisk_pris'][$i]." Kr.</td>";
$message .= "<td style='text-align:left;' style='color:#000' bgcolor='#F2F4FF'>".$_SESSION['basket']['count'][$i]."</td>";
$price = $_SESSION['basket']['fisk_pris'][$i] / $_SESSION['basket']['fisk_gram'][$i];
$total = $price * $_SESSION['basket']['count'][$i];
$message .= "<td style='text-align:right;' style='color:#000' bgcolor='#F2F4FF'>".$total." DKK.</td>";
$totalprice = $totalprice + $total;
$message .= "</tr>";
};
$message .= "</table>";
$message .= "<table width='980px' border='0' align='center' cellspacing='0'>";
$message .= "<tr>";
$message .= "<td><hr></td>";
$message .= "</tr>";
$message .= "</table>";
$message .= "<table width='980px' border='0' align='center' cellspacing='0'>";
$message .= "<tr>";
$message .= "<td>Total Pris inkl. moms: </td>";
$message .= "<td colspan='3' style='text-align:right;'>"; $message .= "".$totalprice.""; $message .= " DKK.</td>";
$message .= "</tr>";
$message .= "</table>";
$message .= "<table width='980px' border='0' align='center' cellspacing='0'>";
$message .= "<tr>";
$message .= "<td><hr></td>";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td>Hvis der skulle være spørgsmål, er du mere end velkommen til at ringe.<br /><br /></td>";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td>Mvh. ";

$sql = "select * from text where text_id=2";
$query = mysqli_query ($db, $sql) or die (mysqli_error($db));
$res = mysqli_fetch_array ($query);

$message .= nl2br($res['text_b']);
$message .= "</td>";
$message .= "</tr>";
$message .= "</table>";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$sql = "select * from e_orders order by o_id desc limit 1";
$query = mysqli_query($db,$sql) or die (mysqli_error($db));
$res = mysqli_fetch_array($query);

// Additional headers
$headers .= 'To: Victor <eksempel@ofir.dk>' . "\r\n";
$headers .= 'From: eksempel <eksempel@ofir.dk>' . "\r\n";
$headers .= 'Cc: "'.$res["o_mail"]. "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
};
};



11 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 3 karma
Sorter efter stemmer Sorter efter dato
prøv at skriv
Fold kodeboks ind/udKode 

istedet for mail(...);

for at se hvad mail functionen modtager af data.



<< < 12 > >>
t