473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

what's wrong with this MIME mail ?

hi all,

I have a script to send newsletters both in html and text version, all
works fine in email clients but unfortunately not in yahoo mail: it
shows nothing in the body of the message, however if I forward that
mail from yahoo I can see it perfectly again in outlook/eudora.
By some trial and errors I found that without the first 2 headers, it
works fine in yahoo mail too, so what's wrong with my headers ?

Thanks in advance to who can help me about that .

johnny

here's the code ( the relevant part )

// create boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// HEADERS
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative;\n".
" boundary=\"{$mime_boundary}\"";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: me<me@mysite.com>\r\n";
$headers .= "X-Sender: me<me@mysite.com>\n";
$headers .= "Reply-To: me<me@mysite.com>\r\n";
$headers .= "Return-Path: me<me@mysite.com>\n";
$query = mysql_query("SELECT id, email FROM $table ", $db);

while ($to = mysql_fetch_array($query)) {

$recipient = $to[email];

$message_html = 'some HTML here ';

$message_text = ' some text here ';

// MESSAGE TO BE SENT

$message = "This is a MIME message \n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message_text."\n".
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message_html."\n".
"--{$mime_boundary}--\n";

@mail ($recipient, $subject, $message, $headers );
}
?>

Jul 17 '05 #1
2 1726
johnny wrote:
[PHP-generated email not behaving in Yahoo mail]
Here are 2 things you could consider:

1. Use consistent line breaks in the email headers. At the moment you're
using a mixture of "\r\n", "\n", and "". For example:
$headers = "MIME-Version: 1.0\r\n"; // \r\n
$headers .= "Content-Type: multipart/alternative;\n". // \n
" boundary=\"{$mime_boundary}\""; // nothing!
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


I heard some mail systems will only accept "\n", even though the standards
require "\r\n". Anyway, why are you switching to "\n" in the mail body?

2. Are you sure the content of the email is 7-bit clean? Maybe you need to
use quoted-printable encoding instead.

HTH,

Phil

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #2
hi phil,

it seems that using just /n and putting the MIME and content-type
headers after all the other ones works both with email clients and
webmail services.

I came to that after some trials and errors but it sounds to have some
logic to me.

thanks again

johnny

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Agenzia Petracca | last post by:
i wanna send html files (even *.doc) in the body of a mail with this code: <? $userfile = "file.html"; $fp = fopen($userfile, "r"); $file = fread($fp, filesize($userfile)); $file =...
2
by: HishHish | last post by:
I have a Java code that I want to convert it to C-sharp in order to put it in my ASP.NET web application. I used the JLCA (Java Language Conversion Assistant) for conversion, but it gave me many...
2
by: asnowfall | last post by:
I am trying to build System.Mail.MailMessage object out of mime encoded SMTP data. I have following questions Byte byteMailData; //mime encoded STMP data for "email with attachment" 1)...
0
by: J Huntley Palmer | last post by:
Is there a nice tidy php class that will allow me to fetch mail from a pop server and break up and retrieve the different mime parts and such... that is at a higher abstraction than the more...
1
by: fabrizio.viggiani | last post by:
I need to send a mail message to an SMTP server. The .net framework provides System.Net.Mail namespace to send an email: - Build a System.Net.Mail.MailMessage and send it using SmtpClient The...
7
by: Manfred Kooistra | last post by:
I have these pieces of example code that I am trying to figure out: (a) $a = $b->c(); (b) $d->e(); What does "->" do? Where is there a reference/explanation in the PHP manual (or anywhere...
34
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - What online resources are available? ----------------------------------------------------------------------- *...
2
by: urbanedge | last post by:
I've just acquired a site and uploaded to godaddy and the email function won't work. I'm new to php and I'm not able to determine where the issue is. I've commented out $this->header .=...
0
by: pavanponnapalli | last post by:
hi, i am trying to send a mail to lotus notes through a mail. But unfortunately, the mail is not sent to lotos notes if the table, which contains data, which is in my system contains...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.