hey geeks,
I have a small mail script which will cause a PHP script to send a receipt upon clicking the submit button, by an HTML mail. This mail contains special characters, namely 'å', 'ä' and 'ö'. Whatever I try, I can't get these characters to display properly everywhere. In some email clients, these characters show up just fine, whereas in others they show up as question marks or kinda boxes. I've tried sending the mail as UTF-8, as ISO-8859- but I'm seriously stumped.
How do I send a mail from PHP using any characters while guaranteeing that the mail shows up the same everywhere?
I am using Wift Mailer library in order to send email.
Here is my swift mailer script settings -
require_once 'lib/swift_required.php';
-
$transport = Swift_MailTransport::newInstance();
-
-
//Create the Mailer using your created Transport
-
$mailer = Swift_Mailer::newInstance($transport);
-
$message = Swift_Message::newInstance()
-
-
->setSubject($subject)
-
->setTo(array($cust_email => $name))
-
->setFrom(array('info@mohsinrafique.com' => 'Mohsin Rafique'))
-
->setSender('noreply@mohsinrafique.com')
-
->setReturnPath('bounce@mohsinrafique.com')
-
->setPriority(3)
-
->setCharset('utf-8')
-
->setBody($messagebody, 'text/html');
-
Kindly help me out to sort out my problem.
9 8242 Dormilich 8,658
Recognized Expert Moderator Expert
does the HTML mail itself contain any information about the used encoding?
testing myself (Swift 4.0.3 on Linux, Thunderbird 3.0 on Mac, XHTML/UTF-8), I had no problems.
Hmm yes and no too. I mean some static information like subject which is hard coded means
$subject="Bestä tigungsmail";
and some dynamic information came from database but that information is an entity which is encoded by this function -
function charset_decode_utf_8($string) {
-
/* Only do the slow convert if there are 8-bit characters */
-
/* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
-
if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string))
-
return $string;
-
// decode three byte unicode characters
-
$string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e","'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'",$string);
-
// decode two byte unicode characters
-
$string = preg_replace("/([\300-\337])([\200-\277])/e","'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'",$string);
-
return $string;
-
}
-
so this is whole senerio about my html mail content. so how can i fixed that the mail shows up the same everywhere?
Dormilich 8,658
Recognized Expert Moderator Expert
what I mean is, does your HTML contains a line as this? - <meta http-equiv="content-type" content="text/html;charset=utf-8">
Yes but even then it is not working:(
Dormilich 8,658
Recognized Expert Moderator Expert
as some mail clients display the data correctly, it seems that the others don’t support HTML email (good enough) or the encoding. what about a multipart message (html + text)?
Yes i am doing this too. here it go.....! - ->setBody($messagebody, 'text/html');
Dormilich 8,658
Recognized Expert Moderator Expert
that’s not multipart, that’s the mime type of the message body.
Then:(
Will you ellaborate it more
Dormilich 8,658
Recognized Expert Moderator Expert Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# Suppose you want to spam your friend, and you have lots of
# friends. The solution is to write a program to do it. After a gander
# at python docs, one easily found the module for the job.
# see http://python.org/doc/2.3.4/lib/SMTP-example.html
# the code is a bit long with the command line, but the key lies at
# the bottom four lines. The gist is this:
|
by: Roy Danon |
last post by:
Hi,
I'm trying to use ASPmail in order to send an email, for some reason the
email arrives to the recipent but the body isn't sent with it and the
subject is shown as question marks(encoding problems probably)
This is the code :
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = mailer.EncodeHeader(fromtitle)
Mailer.FromAddress= from
Mailer.RemoteHost = "localhost"
|
by: Jonah Olsson |
last post by:
Hi guys,
I'm trying to figure out how to use MailMessage to send mails with a
different return path than the sender if the delivery fails. Here's the
case:
Sender: Joe's Pizza
Sender email: joe@pizza.com
Receiver: Matt Hill (from repository)
|
by: Robert McNally |
last post by:
Hello,
I'm currently learning c# and have been trying to write a simple program
with sockets.
The problem is i'm trying to send an email with an attachment, (which is the
program itself) by using base64. When i run it it sends the email ok, but
and attchment doesn't work i get an error when i run it. The attchment seems
to be bigger (20k) then the orginal (16k) i've included the source which i
have been using. Can someone tell me what...
|
by: krishan123456 |
last post by:
i have tried to send email with attached doc file but when i receive the mail i find the attached file in encoded text instead of actuall attachment.the code that i used to send an email is given below.
function SendMail123($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles){
$OB="----=_OuterBoundary_000";
$IB="----=_InnerBoundery_001";
$Html=$Html?$Html:preg_replace("/\n/","{br}",$Text)
or die("neither text nor...
| |
by: prasenjit2007 |
last post by:
Hello,
can u help me sending Email with attachments using the Class phpMailer.
On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name) 2)To 3) Subject 4) Message5) File input(name abc) - to be sent as an attachment.
This form calls the Class PhpMailer through another form with the following code to send the mail.
<?php
ini_set("include_path",...
|
by: undbund |
last post by:
Hi I am creating a newsletter system. The software should run from
desktop computer (localhost) but be able to send email to anyone on
the internet. Can you guys give me some ideas on how to achieve this.
Thanks
|
by: Markgoldin |
last post by:
I am sending an XML data from not dontnet process to a .Net via socket
listener.
Here is a data sample:
<VFPData>
<serverdata>
<coderun>updateFloor</coderun>
<area>MD2</area>
<zone>BOXING</zone>
<status>Running</status>
<job>1000139233</job>
|
by: Jason1983 |
last post by:
Hello sir,
When iam trying to send emails to my user accounts which are gmail id's using my application it is giving me this error.
Here is the error...
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
Not sending CDONTS created e-mails.
Here is the related code ....
'********************************************************
'Creating CDONTS mail object and sending mail to user
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |