budimir Posted September 4, 2008 Share Posted September 4, 2008 Hey guys, Does anyone know how to change encoding when sending email with mail(). I'm from Croatia and we have some special characters. My pages display everything OK, but when I send an email with these special chaaracters I get some strange things. This is my code: <?php // Podaci za email poruku $to = "[email protected]"; $subject = "Obavijest o reklamaciji br. XXX"; $poruka = "Ovo je obavijest o zaprimljenoj, obrađenoj i odobrenoj reklamaciji broj XXXX. Dijelovi će biti danas poslani i možete ih očekivati kroz nekoliko dana"; // Postavke email protokola ini_set('SMTP', 'server'); ini_set('smtp_port', 25); // Slanje emaila if(mail($to,$subject,$poruka,"FROM: [email protected]")){ echo "Poruka je uspješno poslana na @xx.hr!"; } else { echo "Poruka nije poslana!"; } ?> The result I'm getting is something you can see on the screen!! Does anyone know why is this happening and how to change it??? I really don't know what to do ... I tried everything I new ... Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/ Share on other sites More sharing options...
DjMikeS Posted September 4, 2008 Share Posted September 4, 2008 $headers .= "Content-type: text/plain; charset=utf-8\r\n"; Of course you need to change to charset to what you need...should work that way. PS: you also need to include the $headers in your mail function Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633460 Share on other sites More sharing options...
budimir Posted September 4, 2008 Author Share Posted September 4, 2008 Still not working, I tried that before. It's like it's ignoring the encoding. <?php // Podaci za email poruku $to = "[email protected]"; $subject = "Obavijest o reklamaciji br. XXX"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $poruka = "Ovo je obavijest o zaprimljenoj, obrađenoj i odobrenoj reklamaciji broj XXXX. Dijelovi će biti danas poslani i možete ih očekivati kroz nekoliko dana"; // Postavke email protokola ini_set('SMTP', 'server'); ini_set('smtp_port', 25); // Slanje emaila if(mail($to,$subject,$poruka,"FROM: [email protected]",$headers)){ echo "Poruka je uspješno poslana na @drezga.hr!"; } else { echo "Poruka nije poslana!"; } ?> Any more ideas??? It's killing me. I don't understand what's wrong. I have tried diferrent encoding types and nothing worked... ??? Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633464 Share on other sites More sharing options...
DjMikeS Posted September 4, 2008 Share Posted September 4, 2008 Sorry, my bad...it doesn't give you an error ? you need to remove the dot... $headers = "............... Also you need to find out which character set supports your extra chars....maybe it's not utf8..... Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633470 Share on other sites More sharing options...
budimir Posted September 4, 2008 Author Share Posted September 4, 2008 OK, So here is the problem: When I try to echo the message which I'm trying to send in the email, it looks OK. When I send the email, the message is all messed up. The encoding I'm using is UTF-8 and it works perfectly, but it does not apply to the email message. Any ideas??? Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633497 Share on other sites More sharing options...
budimir Posted September 4, 2008 Author Share Posted September 4, 2008 Ihaaaaaaaaaa!!!!!! I got it. Thanks for your effort. Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633503 Share on other sites More sharing options...
DjMikeS Posted September 4, 2008 Share Posted September 4, 2008 My god...you aren't going to tell us what you did....? That's no community spirit.... Link to comment https://forums.phpfreaks.com/topic/122676-solved-different-encoding-with-mail/#findComment-633504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.