pitris Posted February 4, 2009 Share Posted February 4, 2009 Hi, I'm trying to send an HTML email, which includes an image, and contains some portuguese language specific characters, using phpmailer. My code looks like this: require_once('phpmailer_v2.3/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = EMAIL_USERNAME; // SMTP username $mail->Password = EMAIL_PASSWORD; // SMTP password $mail->From = EMAIL_FROM; $mail->FromName = EMAIL_FROMNAME; $mail->AddAddress($email); $mail->WordWrap = 50; // set word wrap $mail->IsHTML(true); // send as HTML $mail->CharSet = "utf-8"; $mail->AddEmbeddedImage('myimg.png','myimg','myimg.png'); $MailBody = '<HTML><BODY><IMG SRC="cid:myimg><br><br>'.$EmailTextPT. "<br><br><br>".EMAIL_FOOTER."</BODY></HTML>"; $mail->Subject = utf8_encode(EMAIL_SUBJECT); $mail->Body = utf8_encode($MailBody); $result = $mail->Send(); $EmailTextPT contains some text with Portuguese characters. The email subject also contains some Portuguese characters. The email is sent but when I open it in gmail it's not recognized as an html email (the body is displayed as plain text with the html tags "showing" and the image is received as an attachment). When I open the email in mac os x email client, I only see the subject and the image, but the text is absent. What am I doing wrong? Thanks in advance, Pedro Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted February 4, 2009 Share Posted February 4, 2009 i personally use pear mail and mail_mime is much easier and has manual. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted February 4, 2009 Share Posted February 4, 2009 you need to specify if the image is inline or attachment plus you need the content type of the image, if you just want to show the image inside your html then you must link it to the existing image ion your server eg, <img src='servername/imeages/imagename.jpg'> this will be easiest. you can not send an image in an email without inserting it into the header, if u just want to show the email then you should link to the remote server where the image is, you dont send images as attachments man unless u have to. Quote Link to comment Share on other sites More sharing options...
pitris Posted February 4, 2009 Author Share Posted February 4, 2009 Thanks for your reply. So there's nothing blatantly wrong with the code? Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted February 4, 2009 Share Posted February 4, 2009 as far as i can see no but i have never used php mailer, unless you need to send them the image which your not meant to do, you should store the image on therver and link back to it. Quote Link to comment Share on other sites More sharing options...
pitris Posted February 4, 2009 Author Share Posted February 4, 2009 I'll try to do that, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.