/    Sign up×
Community /Pin to ProfileBookmark

My script creates HTML emails and passes them to the mail() function (i’ve verified that the message is intact before the mail function) but when i receive the email, its missing characters causing it to display incorrectly. I’ve tried different email addresses, so its not the actual receiving program. so now all i can think of is its some sort of header problem, or the outgoing mail server is messing it up.

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@TeufelAug 27.2009 — I had a similar problem when using special characters in the subject.

This worked for me:

http://de3.php.net/manual/en/function.mb-encode-mimeheader.php#67186
Copy linkTweet thisAlerts:
@toenailsinauthorAug 27.2009 — didn't work for me. i'm going to try and post some examples
Copy linkTweet thisAlerts:
@toenailsinauthorAug 28.2009 — actually, it works for gmail, so could it be something to do with microsoft? i tried it with outlook and hotmail which both stripped stuff
Copy linkTweet thisAlerts:
@DanUKAug 28.2009 — Hi,

You are sending the MIME-Version and Content-Type headers, right?

If so, could you post your mail headers?
Copy linkTweet thisAlerts:
@toenailsinauthorAug 28.2009 — i've replaced all the email addresses with two underscores

[CODE]User-Agent: CodeIgniter
Date: Sat, 29 Aug 2009 02:26:05 +1200
From: "Support" <__>
Return-Path: <__>
Reply-To: "__" <__>
X-Sender: [email]__[/email]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <__>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4a97e8fd90b49"

...

--B_ALT_4a97e8fd90b49
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

...

--B_ALT_4a97e8fd90b49
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

...[/CODE]
Copy linkTweet thisAlerts:
@DanUKAug 28.2009 — I meant more of what you send the headers as from PHP.

For example, this should work okay:

[code=php]
$subject = "subject here";
$headers = "From: You <[email protected]>n";
$headers .= "MIME-Version: 1.0n";
$headers .= "Content-Type: text/html; charset=iso-8859-1n";

$msg = "line 1";
$msg .= "line 2 and so on...";

mail(to-email, $subject, $msg, $headers);
[/code]
Copy linkTweet thisAlerts:
@toenailsinauthorAug 29.2009 — i'm using the CodeIgniter framework which has its own email library
Copy linkTweet thisAlerts:
@toenailsinauthorAug 29.2009 — i made a dump of the data right before the mail() function is called

i am unable to get the resulting email at the moment. I can't get the source from hotmail and i don't have outlook set up on this pc

[upl-file uuid=8aa2856b-49cf-4cd5-9f6a-1ce982a97446 size=20B]recipients.txt[/upl-file]

[upl-file uuid=a13a31eb-c5c6-492d-bee1-4cb2845881ef size=52B]subject.txt[/upl-file]

[upl-file uuid=725ab7b1-5031-4940-b780-7c2df6acbcbb size=5kB]body.txt[/upl-file]

[upl-file uuid=705abf0f-9cf4-4eae-a8eb-1138bb2c89df size=2kB]headers.txt[/upl-file]
Copy linkTweet thisAlerts:
@toenailsinauthorAug 30.2009 — finally worked out the problem. I had removed a function from the codeignitor's email library which escaped all the html. I did this because it was putting random equal signs throughout the emails. I put the function back in, and removed the part in the function that added the equal signs. everything seems to be in order now.
×

Success!

Help @toenailsin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...