Avatar billede jajoh Seniormester
28. januar 2017 - 11:33 Der er 23 kommentarer og
2 løsninger

Problemer med Æ,Ø og Å

hejsa.
Har fundet et nyhedsmail system, spm jeg godt kunne bruge.
Men når jeg modtager mailen fra systemet på min pc kan den ikke skrive æ,ø eller å, men det virker ok hvis modtager mailen på en Iphone eller en Ipad.
Håber der er nogen der kan hjælpe med det problem.
Filerne ser sådan ud
___________________________________________________________
sendmaillist.php:
_____________

<?php
/*
NewsLetter Script - Version 2.0

Copyright (c)2016, http://nedfile.nl

This NewsLetter script was created/adapted by Admin / NedFile.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the nedfile.nl nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO,  THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS  FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN  NO  EVENT  SHALL  NEDFILE.NL  BE LIABLE FOR ANY DIRECT,
INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL  DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR  TORT
(INCLUDING  NEGLIGENCE  OR  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

# Protect the form -> choose a password
$my_password = "pass";

$from_email = "NewsLetter <XXXXXXXX>";

$replayto = "noreply@mail.com";

$mailbottom = "
-----------------------------------------------------------------------------------
To remove youself from this list go to: http://subscribe/subscribe.php
";



# The file where emails are stored
$emails_file = "emaillist.txt";


if (isset($_POST['mailall'])){

$subject = $_POST["subject"];

$message = $_POST["messa"];

if ($_POST["pass"] !== $my_password) $error = "Password is not oke";

if($message == '') $error = "Message is empty";

if($subject == '') $error = "Subject is empty";

}
       
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NewsLetter</title>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>

<body>
<div class="top" align="center">
  <div align="left" style="width:700px; font-size:14px; color:#FFFFFF"><b>Subscribe NewsLetter Script V2.0</b></div>
</div>
       

<div align="center" style="padding-top:80px;">
<div class="cover" align="center">
<font style="color:#009999; font-size:18px">Form to send a Message to the Newsletter subscribers.</font><br />

<font color="#4F4F4F" size="2" face="Verdana">Send here your news message to all the subscribers</font>


<div style="padding-left:100px">


<?php

if($error == ''){
if ($_POST["pass"] == $my_password){

$message.= $mailbottom;

// Read the file with emails
$emails_file = file_get_contents($emails_file);

// Extract list of emails
preg_match_all("/<.{0,100}?>/",$emails_file,$emails_array);

// Start output
ob_implicit_flush(true);

// Send email to each email
foreach ($emails_array[0] as $email){

        // remove "<" and ">" from each email
        $email = substr($email,1,strlen($email)-2);
       
        // Next line is the one sending the email: the key command of this script
        mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain");
       
        // Each time an email is send, output it
        $ret[] = "<br>$email";
       
        // After sending each email, send previous line (the email) to the browser
        echo "$email<br>";

        for($k = 0; $k < 40000; $k++) echo ' ';
   
        usleep(500000); // Don't bombard mail server, wait 0.5 sec between sending.

}

echo "<br><b>Message sending complete!</b>";

  }
 
  }

?> 

&nbsp;</div>


<?php
if($error){
?>

<script type="text/javascript">
// close the errordiv in secs
window.setTimeout("close();", 4000);

function close(){
document.getElementById("errordiv").style.display="none";
}
</script>

<?php   
}   
?>
<div>

     
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"  method="post" >
<table width="500" border="0" cellspacing="0" cellpadding="0">
        <tr>
    <td width="80"></td>
    <td><div style="height:24px;"><div id="errordiv" style="display:block; color:#FF3535"><b><?php if($error) echo $error; ?></b></div>&nbsp;</div></td>
      </tr>
  <tr>
    <td  valign="top"width="80">Subject:
</td>
    <td><input name="subject" size="30" type="text" value="<?=$subject?>"><br />&nbsp;
</td>
   
  </tr>
  <tr>
    <td valign="top">Message:</td>
    <td><textarea name="messa" cols="50" rows="8"><?=$message?></textarea><br />&nbsp;
</td>
    </tr>
<tr>
    <td width="80">Password:</td>
    <td><input type="password" name="pass" size="10"></td>
   
  </tr>
 
 
  <tr>
    <td width="80"></td>
    <td><br />
<br />
<input type="submit" class="button" value="Send email to all" name="mailall"></td>
   
  </tr>
 
</table>

</form>
    </div> 
</div>

</div>

<div class="cleaner"></div>

</body>

</html>

___________________________________________________________

subscribe:
_________


<?php
/*
NewsLetter Script - Version 2.0

Copyright (c)2016, http://nedfile.nl

This NewsLetter script was created/adapted by Admin / NedFile.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the nedfile.nl nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO,  THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS  FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN  NO  EVENT  SHALL  NEDFILE.NL  BE LIABLE FOR ANY DIRECT,
INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL  DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR  TORT
(INCLUDING  NEGLIGENCE  OR  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


if (isset($_POST['listmail'])){

// GET EMAIL
        $email = $_POST["email"];
       
        $email = strtolower($email);


if($email == '') $error = "Email is empty";

if($error == ''){
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  $error = "Invalid email format";
}
}


$action = $_POST["action"];

$file = "emaillist.txt";

if($error == ''){
if (file_exists($file)){
        // If the file is already in the server
        $file_content = file_get_contents($file);
    }else{
 
        $cf = fopen($file, "w") or die("Error: file does not exits");
        //fputs($cf, "Mailing list subscribers\n");
        fclose($cf);
      }
      }
     
     

// IF REQUEST -> ADD EMAIL TO THE FILE
if($error == ''){
if ($action == "subc"){

        // check whether the email is already registered
        if(strpos($file_content,"<$email>") > 0) $error = "Your email is already included in the mailing list.";
        if($error == ''){
        // write the email to the list
        $cf = fopen($file, "a");
        fputs($cf, "\n<$email>");
        fclose($cf);
        // notify subscription
        $error = "Your email has been added to the mailing list.";
}
}
}

// IF REQUEST HAS BEEN TO UNSUBSCRIBE FROM MAILING LIST, REMOVE EMAIL FROM THE FILE
if($error == ''){
if ($action == "unsubc"){
        // if email is not in the list, display error
        if(strpos($file_content,"<$email>")==0) $error = "Your email is not included in the mailing list.";
        if($error == ''){
        // remove email from the content of the file
        $file_content=preg_replace ("/\n<$email>/","",$file_content);
        // print the new content to the file
        $cf = fopen($file, "w");
        fputs($cf, $file_content);
        fclose($cf);
        // notify unsubscription
        $error = "Your email has been removed from the mailing list.";
}
}
}
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NewsLetter</title>
<link rel="stylesheet" href="style.css" type="text/css"/>

</head>

<body>

 
  <div class="top" align="center"><div align="left" style="width:700px; font-size:14px; color:#FFFFFF"><b>Subscribe NewsLetter Script V2.0</b></div></div>
   
       

   
<div align="center" style="padding-top:80px;">

<div class="cover" align="center">

<table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
   
        <td valign="top">
<font style="color:#009999; font-size:18px">Subscribe to Newsletter script V2.0</font>
</td>
       
    </tr>
    <tr>
      <td valign="top" style="padding-top:5px;"><font color="#4F4F4F" size="2" face="Verdana">
      If you would like to stay updated about the latest updates, scripts and patches subscribe<br />
to the newsletter.<br /><br />
</font></td>
      </tr>
</table>

<?php
if($error){
?>

<script type="text/javascript">
// close the errordiv in secs
window.setTimeout("close();", 4000);

function close(){
document.getElementById("errordiv").style.display="none";
}
</script>

<?php   
}   
?>
 
<div align="center" style="padding-top:30px;">

          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
       
        <table width="500" border="0" cellspacing="0" cellpadding="0">
        <tr>
    <td width="80"></td>
    <td><div style="height:24px;"><div id="errordiv" style="display:block; color:#FF3535"><b><?php if($error) echo $error; ?></b></div>&nbsp;</div></td>
   
  </tr>
  <tr>
    <td width="80">your Email:</td>
    <td><input name="email" size="30" type="text"></td>
   
  </tr>
  <tr>
    <td></td>
    <td><br />
<input name="action" value="subc" checked="checked" type="radio"> Subscribe &nbsp;&nbsp;
                        <input name="action" value="unsubc" selected="" type="radio"> Unsubscribe</td>
   
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><br /><br /><input class="button" value="Submit" type="submit" name="listmail"></td>
   
  </tr>

</table>

    </form>   
       
       
        </div>
       
       
       
        </div>
       
       
    </div>


                    <div class="cleaner"></div>
       

</body>

</html>
__________________________________________________________
Htaccess:
_________


RewriteEngine on

#show an alternate image
 
RewriteRule \.(txt)$ http://google.com [NC,R,L]
___________________________________________________________
style:
______


body {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
    color: #404040;
    background-color:#F3F3F3;
    margin: 0;
    }
   
.top{
    width:100%;
    height:30px;
    line-height:30px;
    position: absolute;
    top:0;
    background-color:#706470;
    }
   
.cover{
    background-color:#F7F7F7;
    width:600px;
    padding:10px 30px 40px 30px;
    border:solid 1px #CCCCCC
    }   
   

.button {       
    background-color: #ddd;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
    background-image: -webkit-linear-gradient(top, #fff, #ddd);
    background-image: -moz-linear-gradient(top, #fff, #ddd);
    background-image: -ms-linear-gradient(top, #fff, #ddd);
    background-image: -o-linear-gradient(top, #fff, #ddd);
    background-image: linear-gradient(top, #fff, #ddd);
    -moz-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
    -webkit-box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
    box-shadow: 0 0 1px 1px rgba(255,255,255,.8) inset, 0 1px 0 rgba(0,0,0,.3);
    background-color:#f9f9f9;
    -moz-border-radius:3px;
    -webkit-border-radius:3px;
    border-radius:3px;
    border:1px solid #777777;
    display:inline-block;
    cursor:pointer;
    color:#333333;
    font-family:Arial;
    font-size:12px;
    padding:3px 8px;
    text-decoration:none;
}
   
.button:hover {
    background-color: #eee;       
    background-image: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#e8e8e8));
    background-image: -webkit-linear-gradient(top, #fafafa, #e8e8e8);
    background-image: -moz-linear-gradient(top, #fafafa, #e8e8e8);
    background-image: -ms-linear-gradient(top, #fafafa, #e8e8e8);
    background-image: -o-linear-gradient(top, #fafafa, #e8e8e8);
    background-image: linear-gradient(top, #fafafa, #e8e8e8);
}
Avatar billede kthiesen Novice
28. januar 2017 - 11:41 #1
Du skal se på linjerne

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

Der skal stå DA i stedet for EN
Avatar billede jajoh Seniormester
28. januar 2017 - 12:06 #2
Ok prøver jer, hvor mange steder står det ??
bare så jeg er sikker :-)
Avatar billede jajoh Seniormester
28. januar 2017 - 12:10 #3
Har fundet 1 sted i sendmaillist.
Det hjælper ikke :-(
Avatar billede kthiesen Novice
28. januar 2017 - 12:36 #4
lav en søg/erstat på <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
erstat med <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//DA"

Der er flere steder i den kode du har sendt, der skal rettes til dine egne værdier, f.eks.
To remove youself from this list go to: http://subscribe/subscribe.php - den tænker jeg ikke passer på din opsætning...
Avatar billede jajoh Seniormester
28. januar 2017 - 12:57 #5
Har nu ændret ALLE de steder og der virker stadig ikke.
Avatar billede arne_v Ekspert
28. januar 2017 - 15:38 #6
Der er ingen MIME header, ingen encoding eller charset mail headers.

Det ville vaere ret overraskende hvis det virkede med danske bogstaver.

Find et af de tidligere spoergsmaal omkring PHP email og danske bogstaver der viser hvordan man saette de rigtige MIME headere.
Avatar billede jajoh Seniormester
28. januar 2017 - 16:00 #7
Hej Arne.
Ja ville være nemt, hvis man kunne finde ud af det.
Nok derfor jeg prøver at finde og fandt dette på nettet.
Men hvorfor virker det så på min Iphone og Ipad bare ikke når det modtages på PC
Avatar billede arne_v Ekspert
28. januar 2017 - 16:32 #8
Avatar billede arne_v Ekspert
28. januar 2017 - 16:34 #9
Der er meget information paa nettet, men der er ingen kvalitetskontrol af det der postes.

Du var uheldig med det script du fandt.

Det er netop et kendetegn ved daarlige loesninger at de nogen gange virker og andre gange ikke virker. Gode loesninger er dem som altid virker.
Avatar billede jajoh Seniormester
28. januar 2017 - 16:46 #10
Ja men da ikke meget hjælp i det du skriver
Avatar billede arne_v Ekspert
28. januar 2017 - 17:01 #11
Foelg linket i #8 og scroll ned. Der er der et kode eksempel som virker.
Avatar billede jajoh Seniormester
28. januar 2017 - 17:26 #12
Kan ikke finde det
Håbet det var noget der kunne downloades.
Avatar billede arne_v Ekspert
28. januar 2017 - 17:40 #13
der er en function i indlaeg #33
Avatar billede arne_v Ekspert
28. januar 2017 - 19:00 #14
Hvis du hellere vil have noget kode fra mig, saa kan du godt faa det, men ...


<?php

class SmartMailer {
    // content types
    const TYPE_UNKNOWN = 100;
    const TYPE_TEXT = 101;
    const TYPE_HTML = 102;
    // character sets
    const CS_UNKNOWN = 200;
    const CS_USASCII = 201;
    const CS_ISO88591 = 202;
    const CS_UTF8 = 203;
    // default character set if 8 bit and not possible to guess
    private $default_cs;
    // constructor
    public function __construct() {
        $this->default_cs = SmartMailer::CS_UTF8;
    }
    // access default charcter set
    public function get_default_cs() {
        return $this->default_cs;
    }
    public function set_default_cs($cs) {
        cs_type_to_string($cs); // will throw exception if unknown character set
        $this->default_cs = $cs;
    }
    // convert content type code to actual content type string
    private function type_code_to_string($type) {
        switch ($type) {
            case SmartMailer::TYPE_TEXT:
                return "text/plain";
            case SmartMailer::TYPE_HTML:
                return "text/html";
            default:
                throw new Exception('Unsupported content type code ' . $type);
        }
    }
    // convert character set code to actual character set string
    private function cs_code_to_string($cs) {
        switch ($cs) {
            case SmartMailer::CS_USASCII:
                return "US-ASCII";
            case SmartMailer::CS_ISO88591:
                return "ISO-8859-1";
            case SmartMailer::UTF8:
                return "UTF-8";
            default:
                throw new Exception('Unsupported character set code ' . $cs);
        }
    }
    // attempt to guess character set
    private function guess_cs($s) {
        $s8bit = array_filter(str_split($s), function($c) { return ord($c) >= 128; });
        if(count($s8bit) == 0) return SmartMailer::CS_USASCII;
        $s8bitnbsp = array_filter($s8bit, function($c) { return ord($c) == 0xA0; });
        $s8bitlatin = array_filter($s8bit, function($c) { return ord($c) >= 0xC0; });
        if(count($s8bitnbsp) == 0 && count($s8bitlatin) > 0) {
            return SmartMailer::CS_ISO88591;
        } else if(count($s8bitnbsp) > 0) {
            return SmartMailer::CS_UTF8;
        } else {
            return $this->default_cs;
        }
    }
    // header encode
    private function header_encode($hdr) {
        $hdrcs = $this->guess_cs($hdr);
        if($hdrcs == SmartMailer::CS_USASCII) {
            return $hdr;
        } else {
            return '=?' . $this->cs_code_to_string($hdrcs) . '?Q?' . quoted_printable_encode($hdr) . '?=';
        }
    }
    // email address encode
    private function email_address_encode($addr) {
        $addrparts = explode(' <', $addr);
        if(count($addrparts) == 2) {
            return $this->header_encode($addrparts[0]) . ' <' . $addrparts[1];
        } else {
            return $addr;
        }
    }
    // actual send
    public function send_email($from, $to, $subject, $body, $type = SmartMailer::TYPE_TEXT, $cs = SmartMailer::CS_UNKNOWN) {
        $from = $this->email_address_encode($from);
        $to = $this->email_address_encode($to);
        $subject = $this->header_encode($subject);
        $bodycs = ($cs == SmartMailer::CS_UNKNOWN) ? $this->guess_cs($body) : $cs;
        $contenttype = $this->type_code_to_string($type) . ': charset=' . $this->cs_code_to_string($bodycs);
        if($bodycs == SmartMailer::CS_USASCII) {
            $contentencoding = '7bit';
        } else {
            $contentencoding = 'quoted-printable';
            $body = quoted_printable_encode($body);
        }
        $headers = "From: $from\r\n" .
                  "Content-Type: $contenttype\r\n" .
                  "MIME-Version: 1.0\r\n" .
                  "Content-Transfer-Encoding: $contentencoding";
        mail($to, $subject, $body, $headers);
    }                 
}

?>
Avatar billede jajoh Seniormester
28. januar 2017 - 19:28 #15
Som skrevet tidligere, er dette ikke noget jeg kan, så hvad skal jeg med denne ??
Avatar billede arne_v Ekspert
28. januar 2017 - 20:16 #16
Rettelse:


<?php

class SmartMailer {
    // content types
    const TYPE_UNKNOWN = 100;
    const TYPE_TEXT = 101;
    const TYPE_HTML = 102;
    // character sets
    const CS_UNKNOWN = 200;
    const CS_USASCII = 201;
    const CS_ISO88591 = 202;
    const CS_UTF8 = 203;
    // default character set if 8 bit and not possible to guess
    private $default_cs;
    // constructor
    public function __construct() {
        $this->default_cs = SmartMailer::CS_UTF8;
    }
    // access default charcter set
    public function get_default_cs() {
        return $this->default_cs;
    }
    public function set_default_cs($cs) {
        cs_type_to_string($cs); // will throw exception if unknown character set
        $this->default_cs = $cs;
    }
    // convert content type code to actual content type string
    private function type_code_to_string($type) {
        switch ($type) {
            case SmartMailer::TYPE_TEXT:
                return "text/plain";
            case SmartMailer::TYPE_HTML:
                return "text/html";
            default:
                throw new Exception('Unsupported content type code ' . $type);
        }
    }
    // convert character set code to actual character set string
    private function cs_code_to_string($cs) {
        switch ($cs) {
            case SmartMailer::CS_USASCII:
                return "US-ASCII";
            case SmartMailer::CS_ISO88591:
                return "ISO-8859-1";
            case SmartMailer::UTF8:
                return "UTF-8";
            default:
                throw new Exception('Unsupported character set code ' . $cs);
        }
    }
    // attempt to guess content type
    private function guess_type($s) {
        $res = preg_match('#<(\w+).+</(\w+)#', $s, $matches);
        return ($res && ($matches[1] == $matches[2])) ? SmartMailer::TYPE_HTML : SmartMailer::TYPE_TEXT;
    }
    // attempt to guess character set
    private function guess_cs($s) {
        $s8bit = array_filter(str_split($s), function($c) { return ord($c) >= 128; });
        if(count($s8bit) == 0) return SmartMailer::CS_USASCII;
        $s8bitnbsp = array_filter($s8bit, function($c) { return ord($c) == 0xA0; });
        $s8bitlatin = array_filter($s8bit, function($c) { return ord($c) >= 0xC0; });
        if(count($s8bitnbsp) == 0 && count($s8bitlatin) > 0) {
            return SmartMailer::CS_ISO88591;
        } else if(count($s8bitnbsp) > 0) {
            return SmartMailer::CS_UTF8;
        } else {
            return $this->default_cs;
        }
    }
    // header encode
    private function header_encode($hdr) {
        $hdrcs = $this->guess_cs($hdr);
        if($hdrcs == SmartMailer::CS_USASCII) {
            return $hdr;
        } else {
            return '=?' . $this->cs_code_to_string($hdrcs) . '?Q?' . quoted_printable_encode($hdr) . '?=';
        }
    }
    // email address encode
    private function email_address_encode($addr) {
        $addrparts = explode(' <', $addr);
        if(count($addrparts) == 2) {
            return $this->header_encode($addrparts[0]) . ' <' . $addrparts[1];
        } else {
            return $addr;
        }
    }
    // actual send
    public function send_email($from, $to, $subject, $body, $type = SmartMailer::TYPE_UNKNOWN, $cs = SmartMailer::CS_UNKNOWN) {
        $from = $this->email_address_encode($from);
        $to = $this->email_address_encode($to);
        $subject = $this->header_encode($subject);
        $type = ($type == SmartMailer::TYPE_UNKNOWN) ? $this->guess_type($body) : $type;
        $bodycs = ($cs == SmartMailer::CS_UNKNOWN) ? $this->guess_cs($body) : $cs;
        $contenttype = $this->type_code_to_string($type) . '; charset=' . $this->cs_code_to_string($bodycs);
        if($bodycs == SmartMailer::CS_USASCII) {
            $contentencoding = '7bit';
        } else {
            $contentencoding = 'quoted-printable';
            $body = quoted_printable_encode($body);
        }
        $headers = "From: $from\r\n" .
                  "Content-Type: $contenttype\r\n" .
                  "MIME-Version: 1.0\r\n" .
                  "Content-Transfer-Encoding: $contentencoding";
        mail($to, $subject, $body, $headers);
    }                 
}

?>
Avatar billede arne_v Ekspert
28. januar 2017 - 20:17 #17
Brug:

$mailer = new SmartMailer();
$mailer->send_email($from, $to, $subject, $body);
Avatar billede Zochko Juniormester
28. januar 2017 - 20:33 #18
Hej jajoh :)

Prøv lige der hvor du har dette stykke kode:

// Next line is the one sending the email: the key command of this script
mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain");

At tilfører utf-8 til mail headeren :)
Så det ser sådan her ud:

mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain; charset=UTF-8");

Håber det hjælper dig.
Avatar billede jajoh Seniormester
28. januar 2017 - 20:33 #19
Forstår ikke en meter.
Kan du lave dem og sende dem til min mail johnsen28@gmail.com
Er det filer jeg skal bruge i det jeg har eller hvad skal jeg ???
Hvis det er helt nyt, håber jeg også man selv kan til og fra melde sig nyhedsmailen
og en måde man som admin kun kan sende maile.
Der er sådan det jeg har fundet virker.
Avatar billede Zochko Juniormester
28. januar 2017 - 20:41 #20
Det jeg lige har skrevet ligger allerede i det du har fundet :)

Jeg har fundet denne del:
// Next line is the one sending the email: the key command of this script
mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain");

I det kode som du har kopieret ind i dit spørgsmål.

Og så har jeg sat utf-8 charset på.
Så du skal bare gå i den fil hvor ovenstående står og indsætte dette i stedet:

// Next line is the one sending the email: the key command of this script
mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain; charset=UTF-8");
Avatar billede jajoh Seniormester
28. januar 2017 - 20:58 #21
Super mange tak :-) så virker det.
Avatar billede jajoh Seniormester
29. januar 2017 - 11:53 #22
Mærkelige, efter jeg har sendt et nyhedsmail, så kommer der ikke flere herefter.
Det virker kun en gang, hvorfor det ??
Avatar billede Zochko Juniormester
29. januar 2017 - 12:07 #23
Hej igen Jajoh jeg har set din privat besked.
Jeg svarer dig herinde da jeg synes andre også skal kunne se svaret på et senere tidspunkt.

Ydermere så er det faktisk et nyt spørgsmål, og derfor burde der oprettes et nyt spørgsmål så andre også nemmere ville kunne finde svaret.

Du beskriver du har One.com som webhotel og dem har jeg haft flere som benytter, hvilket gør jeg faktisk godt kan svarer dig på spørgsmålet :)

Jeg har på et tidspunkt skrevet til deres support af samme årsag og svaret er følgende:

One.com tillader ikke udsending af mail via PHP's mail funktion mere end 25 gange om dagen.

Hvordan de validere dette, om det er efter 24 timer siden første mail sendt der bliver nulstillet eller om det er kl.00.00 ved jeg ikke, og det er kun noget som deres support kan svarer på.

Samtidig ved jeg heller ikke om det mail system er noget som du bruger i forbindelse med en hjemmeside men, der er faktisk den mulighed at du kan benytte dig af mailchimp

https://mailchimp.com/

Der kan du sende op til 12.000 mails om måneden gratis (udover koster det.)

Eller du kunne benytte dig af google's smtp server.

Og det vil også være det svar du ville få hos One.com.
Avatar billede Zochko Juniormester
29. januar 2017 - 12:10 #24
Glemte lige :)

Måske ligger mail's i din spam/uønsket mail mappe.

og man kan godt lave en integration til mailchimp (kræver kode kendskab).
https://developer.mailchimp.com/
Avatar billede jajoh Seniormester
29. januar 2017 - 12:26 #25
skal der så laves noget hvis jeg bruger min gmail ??
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

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