URLs in emails sent via mail() don't work / display differently in every mail client
I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.
Instead of the correct version:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into a v)
In Webmail it reads
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!
These are my headers:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers = "Content-Transfer-Encoding: quoted-printable";
$headers = "From: {$sender}";
$headers = "Reply-To: {$sender}";
$headers = "Subject: {$subject}";
$headers = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("rn",$headers));
Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!
php
add a comment |
I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.
Instead of the correct version:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into a v)
In Webmail it reads
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!
These are my headers:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers = "Content-Transfer-Encoding: quoted-printable";
$headers = "From: {$sender}";
$headers = "Reply-To: {$sender}";
$headers = "Subject: {$subject}";
$headers = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("rn",$headers));
Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!
php
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10
add a comment |
I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.
Instead of the correct version:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into a v)
In Webmail it reads
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!
These are my headers:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers = "Content-Transfer-Encoding: quoted-printable";
$headers = "From: {$sender}";
$headers = "Reply-To: {$sender}";
$headers = "Subject: {$subject}";
$headers = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("rn",$headers));
Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!
php
I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.
Instead of the correct version:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into a v)
In Webmail it reads
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!
These are my headers:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers = "MIME-Version: 1.0";
$headers = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers = "Content-Transfer-Encoding: quoted-printable";
$headers = "From: {$sender}";
$headers = "Reply-To: {$sender}";
$headers = "Subject: {$subject}";
$headers = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("rn",$headers));
Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!
php
php
edited Jan 2 at 23:39
Barmar
433k36256357
433k36256357
asked Jan 2 at 22:53
user2999549user2999549
12
12
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10
add a comment |
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10
add a comment |
1 Answer
1
active
oldest
votes
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("rn",$headers));
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014223%2furls-in-emails-sent-via-mail-dont-work-display-differently-in-every-mail-cl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("rn",$headers));
add a comment |
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("rn",$headers));
add a comment |
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("rn",$headers));
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("rn",$headers));
answered Jan 2 at 23:41
BarmarBarmar
433k36256357
433k36256357
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014223%2furls-in-emails-sent-via-mail-dont-work-display-differently-in-every-mail-cl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you don't show us any code, all we can do is guess.
– Mike
Jan 2 at 23:10