Tjenare, jag har gjort ett litet SMTP script här som jag försöker få att funka men jag lyckas inte, den skickar inte ut emailet.
jag använder mig av phpmailer och detta är min kod:
<?
error_reporting(E_ALL);
include "../conn.php";
require("D:\\www\\Apeal\\mail\\david\\phpmailer\\class.phpmailer.php");
ini_set("max_execution_time","9999");
ignore_user_abort(true);
#################
# VARIABLAR #
#################
$text = $_POST['meddelande'];
$subject = $_POST['subject'];
$sender = $_POST['sender'];
$user = $_POST['user'];
$datum = $_POST['datum'];
$tid = $_POST['tid'];
$NewReplyTo = $_POST['sender'];
$avser = 'skarpt';
$databas_arkiv = "test_arkiv";
$databas_epost = "test_mailadresser";
##################
# /VARIABLAR #
##################
if($text!=""){
$sql = "SELECT epost FROM $databas_epost WHERE aktiv='yes'";
$result = mysql_query($sql) OR DIE(mysql_error());
$rows = mysql_num_rows($result); //Hur många aktiva subscribers |Borg
// -- nollställning av räknare och innehållsvariabler
$count = 0;
$fails = 0;
$recepient = "";
$message2 = "<a href=\"http://www.websitensnamn.net/tabort.php?id={$epost}?databas={$databas_epost}\">Vill du inte längre få detta nyhetsbrev. Klicka här</a>\r\n";// ..something
// Nu loopar vi ut alla fjån
while ($row = mysql_fetch_array($result)){
$recepient=$row['epost'];
$mail = new PHPMailer(); //Run the class once
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "127.0.0.1"; // SMTP server 127.0.0.1/localhost
$mail->From = "$sender"; //From whom
$mail->AddAddress('$recepient'); //To whom
$mail->Subject = "$subject"; //Subject
$mail->Body = $text."\n". $message2;//The shit
$mail->IsHTML(true); //Hmmm, wrong place to run this, yes/no?
$count++; //For our summery (Count ALL mails)
if($mail->Send()) //Is the mail sent or not?
{
$check ='Ja'; //What is that variable for?
}
else
{
$check = 'Nej'; //What is that variable for?
//$count = 0; //That is absolutly not a good idea
$fails++; //For our summery (Count ALL failed mails)
}
}
echo "<table width=\"924\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" background=\"img/hem_bak.gif\">
<tr>
<td width=\"40\"> </td>
<td width=\"876\"><font face=\"Verdana\" size=\"1\"><br><br><b>Nu är vi klara!<br>Totalt ".$fails." utav ".$count."mail misslyckades, resten har hittat hem till sin nya ägare.<br></b></font></td>
<td> </td>
</tr>
<tr>
<td colspan=\"3\"><img src=\"img/ner.gif\" width=\"924\" height=\"31\" alt=\"hem_ner\" /></td>
</tr>
</table>";
}
?>