append html <a> tag in php - php

i am using php mail function
$message.='Hi '.$name.', You have been invited to join this, you can do so by following This link, '.$text.'';
$headers = "From: abc#gmail.com" . "\r\n" ."CC: abc#hotmail.com";
$emailTo = $email;
$subject = "Invitation email";
mail($emailTo, $subject, $message, $headers);
it is working fine, but this <a> i am using is either not appended right or not written syntatically correct, the email i get is.
Hi this, You have been invited to join Maggie, you can do so by following
<a
href="http://google.com.pk" class="link"
id="position">this link</a>
, this is a sample email to send.
the tag is written as is, how can i append this <a> into this mail?

You need to specify headers. Take a look.
$message = "Hello, hope you are doing fine.<br>"
. "Please check this:<br>"
. "Anchor text";
$headers = 'MIME-Version: 1.0' . "\r\n"
. 'Content-type: text/html; charset=iso-8859-1' . "\r\n"
. 'From: youremail#yourdomain.com' . "\r\n";
Do use " (double quotes) for message.

Change your headers to or add these
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";

Set headers might help :
$headers = "Reply-To: FROM_NAME <FROM_EMAIL>\r\n";
$headers.= "From: FROM_NAME <FROM_EMAIL>\r\n";
$headers.='X-Mailer: PHP/' . phpversion();
$headers.= "X-Priority: 3\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";

Place this on top:
header("Content-Type: text/html");

The headers shoulds contain the content type...
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Related

PHP email header FROM field not displaying correctly

I need help getting the FROM field in the email to be a specific email address. As of now it is coming out something like this. Looks like its grabbing info off my hosting companies server.
ipw.xxxxxxxxx#boscustweb1302.eigbox.net
All other features of email work great. My $headers are as follows:
$to = $email;
$subject = "ORDER # $tranid";
$headers = "From: info#xxxxxx.com";
$headers = "MIME-Version: 1.0";
$headers = "Content-type: text/html; charset=iso-8859-1";
PHP manual sugest this. Which is pretty much what I am doing, I think.
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
They do use implode, but I don't think I need it the way I have mine setup:
mail($to, $subject, $message, implode("\r\n", $headers));
Tried this with no success:
$to = $email;
$subject = "ORDER # $tranid";
$headers .= "From: info#xxxxxx.com";
$headers .= "MIME-Version: 1.0";
$headers .= "Content-type: text/html; charset=iso-8859-1";
Found the answer with the help of #chris85
$headers = "From: info#xxxxx.com\r\n".
"MIME-Version: 1.0" . "\r\n" .
"Content-type: text/html; charset=UTF-8" . "\r\n";
Keeps HTML format in tack and shows FROM field correctly.

Weird characters in e-mail content only on AOL accounts?

i get clients who complain about weird characters
 Donation Receipt:
Â
If donor provided extra information, here is the information:
Â
this only happens on AOL. Or at least, seems to only happen there.
this is the mail call.
$headers .= "From: " . "Jewcer <info#myapp.com>" . "\r\n";
$headers .= "Reply-To: " . "info#myapp.com" . "\r\n";
$headers .= "From: " . "<{$fromEmail}>" . "\r\n";
$headers .= "Reply-To: " . "{$fromEmail}" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $title, $content, $headers);
Any idea what might causing this problem? generally it works, just AOL and some other odd clients cause problems
the only thing that worked for me was this:
function utf8mail($to,$s,$body,$from_name="x",$from_a = "info#x.com", $reply="info#x.com")
{
$s= "=?utf-8?b?".base64_encode($s)."?=";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8\r\n";
$headers.= "Reply-To: $reply\r\n";
$headers.= "X-Mailer: PHP/" . phpversion();
mail($to, $s, $body, $headers);
}
from
https://stackoverflow.com/a/7267426/533426

CC part is not working in php mail function

I have this php code for mail.
Everythings working fine but the CC part is not working
$headers = "From:".$from."\r\n";
$headers.= "Cc: dainest7138#gmail.com\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$headers.= "Content-Type: text/html; charset=utf-8\r\n";
$headers.= "X-Priority: 1\r\n";
mail($to_mail, $subject2, $mess2, $headers);
Now the mail is being recieved at the address defined in from. The content and all other things are fine but no mail is being recieved on the address defined in "CC" part.
Please Help me understanding the problem.
Thank You
Try this:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From:'.$from. "\r\n";
$headers .= 'Cc: dainest7138#gmail.com' . "\r\n";
mail($to_mail, $subject2, $mess2, $headers);
Re-edited it. Try this one.

php mail header allow ascii characters

On sending a mail I've set my header to:
$headers = 'From: Tómas<tomas#email.com>'. "\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
for mail($to, $subject, $message, $headers);
The Tómas is working in the content correctly but not in the from section of the email. It shows up like Tómas. Any idea how to modify the header to make this work?
Many thanks.
Tó = Tó
change the following line
$headers = 'From: Tómas<tomas#email.com>'. "\r\n";
with
$headers = 'From: Tomas<tomas#email.com>' . "\r\n";

PHP mail() - How to set Priority?

Is there any way to set the priority of PHP mail()? I looked at the online manual but I can't find any reference to it.
By priority, I mean High, Normal, Low or 1, 2, 3 in the headers. So the recipient knows the urgency of the mail.
Thank you!
That's usually done by setting following fields in the header:
"X-Priority" (values: 1 to 5- from the highest[1] to lowest[5]),
"X-MSMail-Priority" (values: High, Normal, or Low),
"Importance" (values: High, Normal, or Low).
See the following example (taken from php's mail function documentation):
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
?>
<?php
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message, $headers);
?>
From: http://www.php.net/manual/en/function.mail.php#91058
Call it with the X-Priority header in the 4th parameter:
mail ( $to, $subject, $message , "X-Priority: 1")
A comment on the PHP mail function documentation said:
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
To define a mail priority you have to put this lines in the headers:
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
?>
http://php.net/manual/en/function.mail.php
everything didn't work except this for my problem
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: xyz#example.com' . "\r\n";
$headers .= 'Cc: Admin#example.com' . "\r\n";
PS: email body must before the headers.

Categories