PHP Disposition-Notification-To - php

I'm trying to get a read receipt from my PHP emails, here's my code:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "From: ABC <do-not-reply#abc.com> \n";
$headers .= "Disposition-Notification-To: abc#hotmail.com \n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
I tried opening the email on my phone and outlook. In both cases, received no email to confirm that the email was open.
I also tried
$headers .= "Read-Receipt-To: abc#hotmail.com \n";
And
$headers .= "X-Confirm-Reading-To: abc#hotmail.com \n";

Read receipts are entirely up to the receiver, there is no way to guarantee one, and many webmail clients will explicitly ignore this for privacy reasons.
Try using Outlook (the office suite application, not the webmail/hotmail clone, not sure which you used) and seeing if you get a popup that says "do you want to send a read receipt? yes / no"

Related

mail(): Multiple or malformed newlines found in additional_header error after change server Plex to Cpanel

i am sending email with attached pdf file. when i am using plex panel below code is working fine now i updated with Cpanel this script could not work. above is code of email .please help me what to do .
i am sending email with attached pdf file. when i am using plex panel below code is working fine now i updated with Cpanel this script could not work. above is code of email .please help me what to do .
$to = $email.",billing#hotelsinkonkan.in";
$from = "billing#hotelsinkonkan.in";
$subject ="Instant e-Bill from www.hotelsinkonkan.in for ".$hotel_name;
$message ="<html><head></head><body style='font-family:Calibri; font-size:11pt; line-height:18px; color:#403437;'>";
$message .="Dear ".$contact.",<br/><br/>";
$message.="<p style='font-size:15px; color:#215868' >Thank you for being our Valued Customer and for using Instant e-Bill service.!</p>";
$message.="We are pleased to present your e-Bill for Advertise on www.hotelsinkonkan.in dated <strong>".date("d-m-y")."</strong> for the period ".$st_date1.' To '.$ed_date1."<br/>";
$message.="<p style='font-size:15px; color:#215868'>We value your relationship with us and assure you our best services at all times.</p>";
$message .="Thanks And Regards<br/>
Billing Hotels In Konkan<br/>
(Active Bit Technologies)<br/>";
$message.="<img style='margin:10px 0px 10px 0px;' src='http://hotelsinkonkan.in/admin/images/logo_mail.jpg'/><br/>";
$message .="Address - Dhayari Industrial Estate,<br/>
Near Pari Automation, Starling<br/>
Nisarga Phase ||, Dhayari<br/><br/>";
$message .="<p style='color:#292727'>Phone no : +91 020 - 32326630</p>";
$message .="<p>Website : www.hotelsinkonkan.in<br/>";
$message .="Email : billing#hotelsinkonkan.in</p>";
$message .="Click Here to Download Hotels in Konkan <a href='http://slideme.org/application/hotelsinkokan'>Apps on Your Mobile</a><br/>";
$message.="<img style='margin:10px 0px 6px 0px;' src='http://hotelsinkonkan.in/admin/images/mail.jpg'/><br/>";
$message.="MPORTANT NOTICE:<br/>
Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender, does not accept liability for any errors or omissions. Active Bit Technologies does not accept liability of mishandling of email account. The information in this email (and any attachments) is confidential. If you are not the intended recipient, you must not use or disseminate this information. If you have received this email in error, please immediately revert to support#activebittechnologies.com and permanently delete the original and any copies or printouts thereof. Although this email and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by Active Bit Technologies. or their subsidiaries or affiliates either jointly or severally, for any loss or damage arising in any way from its use.";
$message .="</body></html>";
echo $message;
$separator = md5(time());
$eol = PHP_EOL;
$filename =$pdf_name.".pdf";
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
mail($to, $subject, "", $headers);

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.

Form doesn't send info to email address (works on others though)

My client has a Wordpress content management system to which I added a simple contact form with a php form handler. The contact form sends the information by email correctly to all three of my email addressses, but when I change to my client's email address the email never arrives. I have run out of ideas where I could look for the problem. No it does not go to his junk mail folder. :)
Sounds like the email is being routed "internally" through your clients network and not out onto the internet. The chances are they have some restrictions on what machines can be used to send emails internally, or the mail routing system sees the internal email as being "different" and does something odd with it.
Try using (from a cli) :
echo "Testing " | mailx -"Test Subject Line" user#company.co.uk
What is the mail function that you are using? Do you attach a header to it? It sounds like it is being marked as spam from the exchange server. What I use (and have always worked for me) is something like this:
`
function mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc="")
{
$subject = nl2br($subject);
$sendmailbody = nl2br($sendmailbody);
if($bcc!="")
{
$headers = "Bcc: ".$bcc."\n";
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8 \nContent-Transfer-Encoding: 8bit\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "From: " . $from . "\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$sendmailbody","$headers");
}
`

Php mail out to mobile / sms / text; missing from, via headers

For some reason, when php mail() is sent to a text number (via email) i.e. 123456789#vtext.com; the from shows up as the centos apache server output email (apache#host-name.com). However, I've included the correct headers; so when the same mail() is pushed to (for example) gmail it comes and shows normal with all the correct headers / mime type / from.
Any idea?
Here's the code for the normal mail
$headers = "From: Alert#thedomain.com \r\n";
$headers .= "Date: ". date('r') . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8";
$headers .= "MIME-Version: 1.0 ";
$body = "body message";
mail($userinfo->username,"thedomain",$body,$headers);
And the code for the mobile: (We don't use date/content type/ mime for text msgs, or else the headers shows up in the txt msg)
$headers = "From: Alert#thedomain.com \r\n";
$body = "body message";
mail($userinfo->mobile,"thedomain",$body,$headers);
Try sending with the additional -f flag to the mail function:
mail($userinfo->username,"thedomain",$body,$headers, "-ffromaddress#example.com");
See the manual for more information on additional parameters

Outlook 2007 receives html mail as source with headers, others MUAs work fine. Why?

I have a couple of simple forms that send an html-only email. Most clients (Gmail, Lotus Notes 8, hotmail/live, windows live mail, outlook express) receive the emails just fine, but Outlook 2007 does not.
The code looks like this:
$data="
<html>
<body>
<strong><u>$sub</u></strong><br><br>
<strong>Name:</strong> {$_POST["nombre"]}<br><br>
<strong>Phone:</strong>{$_POST["telefono"]}<br><br>
<strong>Email:</strong> {$_POST["email"]}<br><br>
<strong>Subject:</strong> {$_POST["asunto"]}<br><br>
<strong>Question:</strong> {$_POST["consulta"]}</strong>
</body>
</html>";
$header = "Reply-To: $from\r\n";
$header .= "From: \"".$_POST["nombre"]."\" <$from>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$enviado = mail($destino,$sub,$data,$header);
($from is the only part of the message validated)
The message received by the customer looks like this:
Content-Type: text/html; charset=iso-8859-1
From: Consulta de "Boss" <boss#myfirm.com>
Reply-To: boss#myfirm.com
X-Mailer: PHP/
<strong><u>Solicitud de envĂ­o de recetas -
CLIENT</u></strong><br><br><strong>Nombre y Apellido:</strong>
Boss<br><br><strong>Email:</strong>
boss#myfirm.com<br><br><br>
Any ideas?
Have you tried sending multipart email, when doing this we never had issues with outlook 2k3 and 2k7 (excepts poor HTML rendering)
<?php
$header = "From: Sender <sen...#domain.org>\r\n";
$header .= "Reply-to: Sender <blabla...#domain.net>\r\n";
$header .= "X-Mailer: Our Php\r\n";
$boundary = "==String_Boundary_x" .md5(time()). "x\r\n";
$boundary2 = "==String_Boundary2_y" .md5(time()). "y\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/related;\r\n";
$header .= " type="multipart/alternative";\r\n";
$header .= " boundary="$boundary";\r\n";
$message = "If you read this, your email client doesn't support MIME\r\n";
$message .= "--$boundary\r\n";
$message .= "Content-Type: multipart/alternative;\r\n";
$message .= " boundary="$boundary2";\r\n";
$message .= "--$boundary2\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "Alternative message in plain text format.\r\n";
$message .= "--$boundary2\r\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "<html><body><p>HTML formatted message</p></body></html>";
You can replace boundaries with whatever you want, but they must be unique.
For more powerful and flexible email sending in php I suggest to use SwiftMailer
EDIT : as Outlook 2007 has a really dumb HTML renderer, you can also try fixing your markup, there is a </font> never opened in your example, dunno if it's the real mail or a typo in question.
I had a very similar problem, try removing the /r from your returns and use only /n. Outlook andd hotmail have trouble with /r/n.
I confirm the experience with Exchange janmoesen has shared.
Had to change CRLF in headers to just LF, then it started working.
(Thank you Microsoft, once again, for having me work 40% time extra.
Also a real thank you to janmoesen for pointing this! This search is over.)
I encountered the same problem with Outlook 2007.
The answer is simple : replace \r\n by \n
I have had trouble with Exchange (not just Outlook) and CRLF in headers with similar results. Basically, we were sending mails (using PHP on Debian with Postfix) with CRLF-separated headers, which would get mangled in Exchange upon arrival. When I changed those \r\n to simply \n, the problem was gone. ("RFCs be damned!", eh?)
YMMV, obviously, since it is not clear whether your other mail clients connect to the same server as Outlook, or use separate servers altogether.
If the message is in HTML you need to identify it as such:
$header .= "Content-Type: text/html; charset=iso-8859-1\r\n";
I have always had better luck with MIME encoded HTML mails. Even if there is just one part, I typically use multipart/mixed and explicitly set the content type (text/html). I'm not very familiar with PHP, but the PEAR::Mail_Mime package looks like a candidate.
http://pear.php.net/package/Mail_Mime
Outlook shouldn't have a problem handling it. (emphisis on shouldn't).
There are lots of problems with HTML email in Outlook 2007.
http://www.molly.com/2007/01/18/what-happened-with-html-and-css-in-outlook-2007/
http://fixoutlook.org/
http://www.developertutorials.com/tutorials/html/microsoft-complicates-html-emails-with-outlook-2007-070130/page1.html
and so on.

Categories