I'm trying to send the message as HTML, but it's arrived as XML Escape!!
Example in screenshot:
second problem is, if i typing the subject in "Arabic language" it's encoded in ANSI.
but if i test to send the same message via Gmail the subject be fine, but the content arrived as XML Escape!!
PHP CODE:
<?php
if(isset($_POST['submit'])){
$to = "email#gmail.com";
$from = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = $first_name . " " . $last_name . " " . "\n\n";
$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
$headers = "From: Brand Name <info#my-dmoain.me>" . "\r\n";
mail($to,$subject,$message,$headers,"-f info#my-dmoain.me");
echo "Thanks";
}
?>
I cant figure out what is wrong.
Thanks
Add concat shorthand .= to this line:
$headers = "From: Ali Najm <ali-najm#iraqnaa.me>" . "\r\n";
You're reassigning $headers var.
Sending nice html with php
Related
Please help me to make code message in line break. i didn't know how to do this please check my code. hope you help me out. thanks alot in advance:-
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail=$_POST['email'];
$msg=$_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$subject2 = "Copy of your form submission";
$message = "Name:-". $first_name . "Email:-". $mail . "Phone Number:-
".$phone. " Message:-".$msg." " ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
?>
I want to recieve message like this:-
Name:-loreal
email:- Mymail
phone Number:- 987654321
Message:- Hi
Try using \n in your message as:
$message = " Name:-". $first_name . "\n Email:-". $mail . "\n Phone Number:-
".$phone. "\n Message:-".$msg." " ;
They're escape sequences. \n is a newline and \r is a carriage return. \r is a Carriage Return \n is a Line Feed (or new line)
Mac: \r
Linux/Unix: \n
Windows: \r\n
When you are using html tags in email template then you have to mention content type in headers and you have to include that headers in mail function like this
$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);
For HTML mail use proper headers:
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail=$_POST['email'];
$msg=$_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$message = "Name:-". $first_name . "<br/>Email:-". $mail . "<br/>Phone Number:-".$phone. "<br/>Message:-".$msg." " ;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to,$subject,$message,$headers);
?>
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail = $_POST['email'];
$msg = $_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$subject2 = "Copy of your form submission";
$message = "Name:-" . $first_name . "\n\n" . "Email:-" . $mail . "\n\n" . "Phone Number:- " .$phone . "\n\n" . " Message:- " . $msg;
$headers = "From:" . $from;
$headers .= " MIME-Version: 1.0\r\n"; #Define MIME Version
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; #Set content type
mail($to,$subject,$message,$headers);
header('Location: thank-you.php');
}
else{
echo 'Your message cannot be sent.';
}
?>
I have a form when a user enters data and submits, it will go to his mail, now I am having problem with keeping my logo in the mail, below is my php code for mail
<?php
if(isset($_POST['submit'])){
$to = "contact#bolstersolutions.com"; // this is your Email address
$from = $_POST['name1']; // this is the sender's Email address
$first_name = $_POST['name2'];
$last_name = $_POST['email2'];
$last_name1 = $_POST['number1'];
$subject = "Referal";
$subject2 = "Your Friend " . $from . " Has Referred You To Us For UK Process";
$message = $from . " has refered the following student :" . "\n\n" . $first_name. "\n\n" .$last_name. "\n\n" .$last_name1;
$message2 = "Your friend " . $from . " has referred you to Bolster Solutions for UK process. We will be more than happy to process your applications, thus helping you in achieving your goals to study MS in UK." . "\n\n" . "Feel free to go to the following url for more information or else you can also call us # +91 9666999430 / 7661919191." . "\n\n" . "URL: https://consultancy.bolstersolutions.com/mail/" . "\n\n" . "Thanks and Regards." . "\n\n" . echo "<img src='https://consultancy.bolstersolutions.com/mail/assets/img/logo.png'>" ;
$headers = "From:" . $from;
$headers2 = "From: Bolster Solutions " . $to;
mail($to,$subject,$message,$headers);
mail($last_name,$subject2,$message2,$headers2);
}
?>
the following error is happening:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\mail\index.php
Can anyone please help me with this, thanks in advance.
Remove echo in $message2
Set headers like this
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
Then send : mail($last_name,$subject2,$message2,$headers);
There is a syntax error near: ..."\n\n" . echo "<img src.... Removing echo should solve it.
Please help me to make code message in line break. i didn't know how to do this please check my code. hope you help me out. thanks alot in advance:-
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail=$_POST['email'];
$msg=$_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$subject2 = "Copy of your form submission";
$message = "Name:-". $first_name . "Email:-". $mail . "Phone Number:-
".$phone. " Message:-".$msg." " ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
?>
I want to recieve message like this:-
Name:-loreal
email:- Mymail
phone Number:- 987654321
Message:- Hi
Try using \n in your message as:
$message = " Name:-". $first_name . "\n Email:-". $mail . "\n Phone Number:-
".$phone. "\n Message:-".$msg." " ;
They're escape sequences. \n is a newline and \r is a carriage return. \r is a Carriage Return \n is a Line Feed (or new line)
Mac: \r
Linux/Unix: \n
Windows: \r\n
When you are using html tags in email template then you have to mention content type in headers and you have to include that headers in mail function like this
$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);
For HTML mail use proper headers:
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail=$_POST['email'];
$msg=$_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$message = "Name:-". $first_name . "<br/>Email:-". $mail . "<br/>Phone Number:-".$phone. "<br/>Message:-".$msg." " ;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to,$subject,$message,$headers);
?>
<?php
if(isset($_POST['submit'])){
$to = "mymail#gmail.com"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail = $_POST['email'];
$msg = $_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$subject2 = "Copy of your form submission";
$message = "Name:-" . $first_name . "\n\n" . "Email:-" . $mail . "\n\n" . "Phone Number:- " .$phone . "\n\n" . " Message:- " . $msg;
$headers = "From:" . $from;
$headers .= " MIME-Version: 1.0\r\n"; #Define MIME Version
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; #Set content type
mail($to,$subject,$message,$headers);
header('Location: thank-you.php');
}
else{
echo 'Your message cannot be sent.';
}
?>
I created a feedback form and have something wrong with $headers, because it works perfect when I give fixed urls to $headers but when i give him variables it stops work. This is my code
<?php
$to = "mail#mail.com";
$name =$_POST['name'];
$email =$_POST['email'];
$subject =$_POST['subject'];
$messege =$_POST['messege'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $email . "\r\n";
$headers .= 'Bcc: ' . $email . "\r\n";
mail($to,$subject,$messege,$headers);
?>
Who can say why?
Share you HTML (form) codes with us to more guidance.
And you can check form method, according to your php codes, form method must be post. and you can echo $_POST['name'] (for example) that you know this filled or empty.
I would like to mail some text as bold in my email content. I have used the following code
$to = 'some#gmail.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$from = $param['email']; // this is the sender's Email address
$headers = "From:" . $from;
$name = $param['name'];
$subject = "Test";
$message = "message.\n\n"
."<b>Name:</b> ".$name . "\n\n"
."Adress: \n"
.$param['address'] . "\n"
.$param['zip'] . ", "
.$param['postal_area'] . "\n\n"
."E-post: ".$param['email'] . "\n\n\n"
mail($to,$subject,$message,$headers);
I have used <strong> also instead of <b> tag, but nothing works.
I get mail in the below format :
<b>Namn:</b> some name
Adress:
BorĂ¥s, Sweden
4837, Boras
E-post: somemail#gmail.com
You are overwriting the header variable again. You need to append to it.
$headers .= "From:" . $from; //You forgot to concatenate here...
// ---^ //Add the .
Try setting the font weight property in a span:
$message = "E-post: <span style='font-weight:strong;'>".$param['email']."</span>";
But also see other reply, you are overwriting the header so it is not reading the message as HTML.