Outlook not showing UTF-8 Encoded Text (یب سائٹ Ù) email by php mail - php

When i am sending UTF-8 email using mail() from my site . Gmail showing it very nice but outlook showing it like this یب سائٹ Ù
my code is
$to = "xxx#gmail.com";
$subject ="Subject";
$headers = "From: xxxx \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset:UTF-8 \r\n";
$message = "email message";
mail ($to,$subject,$message,$headers);

You might want to add encoding to your subject
$subject='==?UTF-8?Q?Subject?='
and/or a Content-Transfer-Header
$headers.='Content-Transfer-Encoding: quoted-printable'
depending on the message part the encoding problem shows.

Related

PHP contact form (spam protection)

Is there a better way (than adding headers such as below) for PHP webforms to be sent directly to inbox and not to junk/spam folders.
$to = $email;
$subject = 'subject here';
$headers = "From: "."emailaddress"."\r\n";
$headers .= "MIME-Version: 1.0 \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 \r\n";
Thank you!
PS. I have access to the Mail Server and Domain(DNS).

php mail Cc not sending email if left blank

I am not sure if anyone can help me with this issues but I currently have a php mailing form. everything works great, I am trying to setup Cc options.
code.
$subject = "Name #$name_id test data";
$mailer ='Company <Support#company.com>';
$headers = "From: $mailer \r\n";
$headers .= "Cc: $cc \r\n";
$headers .= "Reply-To: ". strip_tags($mailer) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body style="background:#eeeeee">';
mail($emailto, $subject, $message, $headers);
cc var is $cc=$VAR["cc_user"]; which is linked to html form. so here is I enter an email address in the html input form and submit, it works. if I leave blank, email does not send. can anyone help me with this.
Thanks so much.
Fixed..
$emailto= $sql['CUSTOMER_EMAIL'].", ".$VAR["cc_user"];

How to send email to yahoo via PHP

I am attempting to send a confirmation email from a PHP script. I tested on gmail and it worked fine (the email was sent with appropriate subject and contents), however when I tried sending an email to a yahoo account, the subject field was correct but the contents were sent as an attachment as opposed to text inside the actual email. Here is the mailing code.
$headers = 'From: ' . 'orders#COMPANY_NAME.com' . "\r\n";
$headers .= 'Reply-To: ' . 'orders#COMPANY_NAME.com' . "\r\n";
$headers .= "BCC: orders#COMPANY_NAME.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text; charset=ISO-8859-1\r\n"
mail($email, "COMPANY_NAME Order Confirmation $confirmation_number", $text, $headers);
How can I send an email to yahoo that will include $text inside the email as opposed to an attachment?
It may be because of a wrong "Content-Type" header: I do not think "text" is a valid content type.You should try, instead, with "text/plain".
Content-Type: text/plain; charset=ISO-8859-1
PS: you may also want to consider using UTF-8 instead of ISO-8859-1.

PHP mail() Not displaying HTML

We've recently upgraded to a Plesk Parallel Linux Server and it appears as if the PHP settings are ignoring headers! The emails are receiving fine, but display the HTML tags.
The phpInfo() file can be viewed here: https://www.pressgofer.com/phpInfo.php
The PHP itself should be okay, but have included it here anyway.
PHP Mail Code
$email = "example#example.com";
$message = "<h1 style='font-family:Helvetica,Arial;font-size:17px'>Your account has a password reset request</h1>";
$headers = "From: noreply#pressgofer.com \r\n";
$headers .= "Reply-To: noreply#pressgofer.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($email, "Reset password notification", $message, $headers);
Many thanks,
Nick
your phpinfo shows that mail.add_x_header is OFF. you need to turn it on
To enable the X-Mail header, set mail.add_x_header to 1 in your php.ini
<?php
$to = "yourplace#somewhere.com";
$subject = "My HTML email test.";
$headers = "From: sinha.ksaurabh#gmail.com\r\n";
$headers .= "Reply-To: sinha.ksaurabh#gmail.com\r\n";
$headers .= "Return-Path: sinha.ksaurabh#gmail.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body>";
$message .= "<h1> This is a test </h1>";
$message .= "</body></html>";
if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
sending mail from php: headers are interpreted as body?
Issue was associated with MIME type and server interpretation- no \r needed.

Getting empty mails from website

I have php 4.x installed in server, I have a script to send mails, generally 1 Out of 10 mails i receive will have no body but the subject will be there. The mail sending code is below.
$headers = "MIME-Version: 1.0 \n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$headers .= "From: Contact Form <contact_form#mycompany.com> \r\n";
$headers .= "Request Form: $name ($contactid)";
$subject = "Request: $name";
$body = "Name: $name<br />Email: $email<br />Phone: $phone<br/>";
mail("myname#gmail.com",$subject,$body,$headers);
What is the reason behind it. Is this the problem with the script i have written or the SMTP server.
According to RFC 2822:
Header fields are lines composed of a field name, followed by a colon (":"), followed by a field body, and terminated by CRLF.
A field name MUST be composed of printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon.
Your header does not follow this format. Some receiving mail servers may be more strict and may refuse your mails because of that. Change it to:
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Contact Form <contact_form#mycompany.com>\r\n";
$headers .= "Request-Form: $name ($contactid)\r\n";
\r : Carriage Return
\n : Line Feed
Does it fix your problem?

Categories