Welcome Guest, Not a member yet? Register   Sign In
why the $&*$ is this happening?
#1

[eluser]sixpack434[/eluser]
We just sent HTML emails to 200 of ours users and they received a bunch of crap mainly containing the word 3D

e.g.

<=3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D= 3D=3D 3D=3D3D 3D=3D3D3D 3D=3D3D3D3D 3D=3D3D3D3D3D 3D=3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D3D3D3D3D 3D=3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D

Also the subject is empty?!? and errors with subject being undefined appears on the page.

Of course our users are not happy and neither am I with codeigniter. Please point out If it was me writing stupid code or if this is codeigniter's fault.

Code:
function emailLesson($lessonNo=0,$start=0,$last=0, $personalMessage=0){

        $query = $this->db->query("SELECT email FROM email ");
        $total = $query->num_rows();
              
              echo "Total emails to send: <h3>$total</h3>";
          
              echo "Sending emails from <b>$start</b> to <b>$last</b>";
              
              
              echo "Refreshing every 30 seconds";
                    
              $query = $this->db->query("SELECT * FROM lesson WHERE lessonNo=$lessonNo");
              $lesson = $query->row();

              $difficulty = $this->lesson->getTypeName($lesson->type);
              $date = date("F jS, Y", strtotime($lesson->dateTime));
              
            $body = "-------------------------------------------------------------------<br>";
            $body .= "<a href='http://www.site/lesson/$lessonNo/". str_replace(' ', '_', $lesson->name) . "'><b>$difficulty - #$lesson->lessonNo $lesson->name ($date) </b></a><br>";
            $body .= "-------------------------------------------------------------------<br><br>";
            $body .= "$lesson->description<br><br>";
            $body .= "-------------------------------------------------------------------<br>";
//            $body .= "You have received this message because you requested email notification on site. If you would like to unsubscribe from these messages in the future please <a href='http://site/unsubscribe.php?ID=$ID&email;=$to'>click here</a><br>";
            if(strlen($personalMessage) > 1){
                $body .= "\n\n$personalMessage\n";
            }
            $body .= "\n\nsite Team\n";              
              
              $query = $this->db->query("SELECT email FROM email UNION SELECT email FROM users WHERE notifications='Y' LIMIT $start, $last");
              $this->email->from('[email protected]','ArabicPod.net');
              $this->email->subject("New Lesson: $difficulty - #$lesson->lessonNo $lesson->name");
              $this->email->message($body);
              foreach($query->result() as $row){
                $this->email->to($row->email);
                $this->email->send();                    
            }    
            
            if($total == $last){
                echo "<h1>Success</h1>";
                echo "Sent email to <b>$total</b>";
                $this->email->print_debugger();
            } elseif($total < $last+50){

header("refresh:30;url=" . base_url() . "admin/email/emailLesson/" . $lesson->lessonNo . "/$last/$total/$personalMessage");
            } else {
                $next = $last+50;
                header("refresh:30;url=" . base_url() . "admin/email/emailLesson/" . $lesson->lessonNo . "/$last/$next/$personalMessage");

            }
      }
#2

[eluser]wiredesignz[/eluser]
There's no point blaming CI, It has to be your fault for not testing your systems thoroughly before going into production.

3D is the ascii character for `=` often seen in emails that contain html.
browser refresh is probably the worst way to run a repetitive task.

EDIT: It seems it is your fault in any case - This from the user guide:

Quote:If you send HTML email you must send it as a complete web page.

Have a nice day Tongue
#3

[eluser]sixpack434[/eluser]
I did test this before sending it to people. basically I commented the loop in the above code to send directly to my personal email

e.g.

Code:
//    foreach($query->result() as $row){
    //            $this->email->to($row->email);
                $this->email->to("[email protected]");
                $this->email->send();                    
        //    }

and it sent the message ok with the subject and everything. So why did it mess up when I ran it in a loop?

It's ridiculous. So i've tested this by sending it to my self, I can't send to to my self 200 times, so am I still to blame or codeigniter?
#4

[eluser]wiredesignz[/eluser]
Your HTML is not a complete web page! Read the user guide.
#5

[eluser]Derek Allard[/eluser]
Sorry to hear about this. Anyhow, run a quick search of these forums for "=3D" also.
#6

[eluser]sixpack434[/eluser]
I guess i'll have to go back to using PHP's mail() as that worked fine in my old website
#7

[eluser]wiredesignz[/eluser]
Or ... you could read the User Guide. Tongue
#8

[eluser]sixpack434[/eluser]
I read the user guide already. As I said, if you can spot an error in my code then point it out and I will happily test my code afterwards. This problem happens when I tried to send the email in a loop. It works ok If I comment the loop. The user guide doesn't say anything about not being able to use the email function in a loop?
#9

[eluser]wiredesignz[/eluser]
The error in your code could be related to this:
[quote author="wiredesignz" date="1201376946"]Your HTML is not a complete web page![/quote]
It has nothing to do with looping, you may be causing the email object to crash with mal-formed HTML. Try it.

Good Luck Wink
#10

[eluser]Craig A Rodway[/eluser]
Considering the default sender transport for the Code Igniter Email class is the mail() function you might as well stick with CI...




Theme © iAndrew 2016 - Forum software by © MyBB