Avatar billede chico-dk Nybegynder
09. april 2006 - 12:24 Der er 8 kommentarer og
1 løsning

Mail problem!

Hej Experter!

Vi bruger et system, som automatisk sender mails ud ved tilmelding af siden, men der sker tit at den aldrig kommer frem til modtageren.

Det kan skyldes at mail programmet tror mailen er junk og smider den i junk mappen. Det sker også at ofir, gmail, hotmail og flere gratis e-mail programmer betragter disse mails som spam og igen får de aldrig mailen.

Hvad kan vi gøre for at afhjælpe dette problem?
Avatar billede hmortensen Nybegynder
09. april 2006 - 13:11 #1
Prøv at vise hvordan du sender mailen.

Der skal nok headers med ellers vil det blive betragtet som spam.
Avatar billede chico-dk Nybegynder
09. april 2006 - 13:28 #2
Vi kører med mail via standard PHP mail() og kunne også vælge UNIX Sendmail program men med samme problem.
Hvis det er en hjælp anvender vi phpprobid auktions script
Avatar billede hmortensen Nybegynder
09. april 2006 - 13:28 #3
Kender ikke overstående script, men kan du ikke sakse mail afsendelses delen ud.
Avatar billede chico-dk Nybegynder
09. april 2006 - 13:33 #4
<?
## v5.20 -> may. 20, 2005
session_start();
if ($_SESSION['adminarea']!="Active") {
    echo "<script>document.location.href='login.php'</script>";
} else {

include ("../config/config.php");

if (isset($_POST['sendnlok'])) {
    if ($_POST['subject']!=""&&$_POST['content']!="") {
        $savedSettings="yes";
        $newsletterContent=stripslashes($_POST['content']);
        htmlmail($_POST['email'],$_POST['subject'],$newsletterContent,
        $setts['adminemail'],$newsletterContent);
    } else {
        $savedSettings="no";
    }
}

include ("header.php"); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td rowspan="2"><img src="images/i_user.gif" border="0"></td>
    <td width="100%"><img src="images/pixel.gif" height="24" width="1"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" align="right" background="images/bg_part.gif" class="head"><? echo $a_lang[USER_MANAGE]; echo " / "; echo $a_lang[USER_NEWS];?>&nbsp;&nbsp;</td>
    <td><img src="images/end_part.gif"></td>
  </tr>
</table>
<br>
<?
echo ($savedSettings=="yes")?"<p align=\"center\">Email successfully sent.</p>":"";
echo ($savedSettings=="no")?"<p align=\"center\">Error: The subject and body fields cannot be empty.</p>":"";
?>
<table width="100%" border="0" cellspacing="2" cellpadding="4">
  <form action="senduseremail.php" method="post">
  <input type="hidden" name="email" value="<?=$_REQUEST['email'];?>">
  <input type="hidden" name="username" value="<?=$_REQUEST['username'];?>">
    <tr>
      <td colspan="2" align="center" class="c3"><b>
        <?=$a_lang[TITLE_INDIV_SEND];?>
        </b></td>
    </tr>
    <tr class="c1">
      <td width="150"><?=$a_lang[SEND_EMAIL_TO];?> 
        :</td>
      <td><strong><?=$a_lang[USERNAME];?></strong> : <?=$_REQUEST['username'];?><br>
      <strong><?=$a_lang[EMAIL];?></strong> : <?=$_REQUEST['email'];?></td>
    </tr>
    <tr class="c2">
      <td><?=$a_lang[SUBJECT];?>
        :</td>
      <td><input name="subject" type="text" id="subject"></td>
    </tr>
    <tr class="c1">
      <td><?=$a_lang[ENTER_CONTENT];?>
        :</td>
      <td><textarea name="content" cols="45" rows="10" id="content"></textarea>
        <script language="JavaScript1.2">
            editor_generate('content');
        </script><br>
        <?=$a_lang[HTML_ALLOW];?></td>
    </tr>
    <tr>
      <td colspan="2" align="center" class="c3"><input name="sendnlok" type="submit" id="sendnlok" value="<?=$a_lang[BTN_SEND_EMAIL];?>"></td>
    </tr>
  </form>
</table>
<?     include ("footer.php");
} ?>
Avatar billede chico-dk Nybegynder
09. april 2006 - 13:36 #5
Det er ofte mails som sendes af systemet som svigter. Dertil bruges denne kode:
<?
## v5.20 -> may. 20, 2005
session_start();
if ($_SESSION['adminarea']!="Active") {
    echo "<script>document.location.href='login.php'</script>";
} else {

include ("../config/config.php");

if (isset($_POST['sendemailok'])) {
    $getInactiveUsers = mysql_query ("SELECT * FROM probid_users WHERE active=0");
    while ($userArray = mysql_fetch_array($getInactiveUsers)) {
        $nbAuctions = getSqlNumber("SELECT id FROM probid_auctions WHERE ownerid='".$userArray['id']."'");
        $nbBids = getSqlNumber("SELECT id FROM probid_bids WHERE bidderid='".$userArray['id']."'");
        $nbFeedbacks = getSqlNumber("SELECT userid FROM probid_feedbacks WHERE userid='".$userArray['id']."'");
        if ($nbAuctions==0&&$nbBids==0&&$nbFeedbacks==0) {
            ## we have deleted the user
            if ($setts['account_mode']==1) {
                if ($fee['is_signup_fee']=="Y"&&$fee['val_signup_fee']>0) $regConfirm=0;
                else $regConfirm=1;
            } else if ($setts['account_mode']==2) $regConfirm=1;
            $recipientId = $userArray['id'];
            if ($regConfirm==1) {
                include ("../mails/register_confirm.php");
            } else {
                ## this doesnt need to be included here
                ## include ("mails/register.php");
            }               
        }
    }
    echo "<script>document.location='index.php'</script>";
} else if (isset($_POST['cancelok'])) {
    echo "<script>document.location='index.php'</script>";
}

include ("header.php"); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td rowspan="2"><img src="images/i_user.gif" border="0"></td>
    <td width="100%"><img src="images/pixel.gif" height="24" width="1"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="100%" align="right" background="images/bg_part.gif" class="head"><? echo $a_lang[USER_MANAGE]; echo " / "; echo $a_lang[ACTIVATION_EMAILS];?>&nbsp;&nbsp;</td>
    <td><img src="images/end_part.gif"></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellspacing="2" cellpadding="4">
  <form action="<?=$PHP_SELF; ?>" method="post">
    <tr class="c3">
      <td align="center"><b>
        <?=$a_lang[ACTIVATION_EMAILS_TITLE];?>
        </b></td>
    </tr>
    <tr align="center" class="c1">
      <td><?=$a_lang[ACTIVATION_EMAILS_MESSAGE];?></td>
    </tr>
    <tr class="c3">
      <td align="center"><input name="sendemailok" type="submit" id="sendemailok" value="<?=$a_lang[BUTT_PROCEED];?>">
&nbsp;
        <input name="cancelok" type="submit" id="cancelok" value="<?=$a_lang[BUTT_CANCEL];?>"></td>
    </tr>
  </form>
</table>
<?     include ("footer.php");
} ?>
Avatar billede hmortensen Nybegynder
09. april 2006 - 13:40 #6
Det kalder en metode der hedder htmlmail()

Kan du prøve at finde den ?
Avatar billede chico-dk Nybegynder
09. april 2006 - 13:56 #7
Det tætteste jeg kommer på det er :
function htmlmail($to, $subject, $msg, $sender, $hmsg = "") {
    global $siteurl, $setts, $htmlfont, $currentVersion;

    ## set date
    $tz = date("Z");
    $tzs = ($tz < 0) ? "-" : "+";
    $tz = abs($tz);
    $tz = ($tz/3600)*100 + ($tz%3600)/60;
    $sendDate = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
   
    $uniq_id = md5(uniqid(time()));

    ## create the message body
    if ($hmsg == "") $hmsg = $msg;
    $htmlmsg .= "<!--\n$msg\n-->\n";
    $htmlmsg .= "<html><body><img src=\"" . $setts['siteurl'] . "images/probidlogo.gif\"><p>$htmlfont" . $hmsg . "</body></html>";

    if ($setts['mailer']=="sendmail") {
        ## send through the UNIX Sendmail function
        $Sendmail = $setts['sendmail_path'];
   
        ## create header
        $header = "";
        $header .= "Date: ".$sendDate."\n";
        $header .= "Return-Path: ".$sender."\n";
        $header .= "To: ".$to."\n";
        $header .= "From: ".$sender." <".$sender.">\n";

        ## admin BCC
        if ($setts['bcc']=="Y") $header .= "Bcc: ".$setts['adminemail']."\n";

        $header .= "Reply-to: ".$sender."\n";
        $header .= "Subject: ".$subject."\n";
        $header .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $_SERVER['SERVER_NAME'], "\n");
        $header .= "X-Priority: 3\n";
        $header .= "X-Mailer: PHPProBid/Sendmail [version " . $currentVersion . "]\n";
        $header .= "MIME-Version: 1.0\n";
        $header .= "Content-Transfer-Encoding: 7bit\n";
        $header .= sprintf("Content-Type: %s; charset=\"%s\"","text/html","iso-8859-1");
        $header .= "\n\n";

        if ($sender != "")
            $sendmail = sprintf("%s -oi -f %s -t", $Sendmail, $sender);
        else
            $sendmail = sprintf("%s -oi -t", $Sendmail);

        if(!@$mail = popen($sendmail, "w")) {
            echo "Could not execute: " . $Sendmail;
        }
       
        fputs($mail, $header);
        fputs($mail, $htmlmsg);
       
        $result = pclose($mail) >> 8 & 0xFF;
        if($result != 0) {
            echo "Could not execute: " . $Sendmail;
        }
    } else if ($setts['mailer']=="mail") {
        ## send through the PHP mail() function
        ## create header
        $boundary[1] = "b1_" . $uniq_id;
        $boundary[2] = "b2_" . $uniq_id;
   
        $header = "";
        $header .= "Date: ".$sendDate."\n";
        $header .= "Return-Path: ".$sender."\n";
        $header .= "From: ".$sender." <".$sender.">\n";

        ## admin BCC
        if ($setts['bcc']=="Y") $header .= "Bcc: ".$setts['adminemail']."\n";

        $header .= "Reply-to: ".$sender."\n";
        $header .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $_SERVER['SERVER_NAME'], "\n");
        $header .= "X-Priority: 3\n";
        $header .= "X-Mailer: PHPProBid [version " . $currentVersion . "]\n";
        $header .= "MIME-Version: 1.0\n";
        $header .= "Content-Transfer-Encoding: 7bit\n";
        $header .= sprintf("Content-Type: %s; charset=\"%s\"","text/html","iso-8859-1");
   
        $params = sprintf("-oi -f %s",$sender);
        if (strlen(ini_get("safe_mode"))<1) {
            $old_from = ini_get("sendmail_from");
            ini_set("sendmail_from",$sender);
            $result = @mail($to, $subject, $htmlmsg, $header, $params);
        } else {
            $result = @mail($to, $subject, $htmlmsg, $header);
        }
        if (isset($old_from)) ini_set("sendmail_from",$old_from);
        if (!$result) echo "Mail Sending Failed..";
    }
Avatar billede chico-dk Nybegynder
16. april 2006 - 13:15 #8
Ingen kunne hjælpe :(
Avatar billede chico-dk Nybegynder
16. april 2006 - 13:19 #9
slutter
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester