PHP Classes

big message to gmail

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in

      Top level forums  >  PHP Specialists  >  General  >  big message to gmail  
Subject:big message to gmail
Summary:message with some big attachments ~1MB don't reach gmail.
Author:sergiy serov
Date:2008-12-24 13:53:18
Update:2008-12-30 01:11:07

  1. big message to gmail   Reply   Report abuse  
Picture of sergiy serov sergiy serov - 2008-12-24 16:56:20
Could somebody please help me with this attachments code, as it doesn't send to gmail big messages (>500KB):

$email_to = ""; // Who the email is to

$headers = "From: ".$name_from." <".$email_from.">"."\r\n";
$headers .= "Reply-To: ".$name_from." <".$email_from.">"."\r\n";

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$semi_rand2 = md5(time());
$mime_boundary2 = "==Multipart_Boundary_x{$semi_rand2}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_message .= "--{$mime_boundary}\n";
$email_message .= "Content-Type:text/plain; charset=UTF-8\n";
$email_message .= "Content-Transfer-Encoding: 7bit\n\n";
$email_message .= $email_txt ."\n";

if ($files != ""){

$fileatt_type = "application/octet-stream"; // File Type
$files_array = explode(",",$files);
$no_files = count($files_array)-1;
for ($a = 0; $a <$no_files; $a++) {

$fileatt = "files/".$files_array[$a]; // Path to the file

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary2}\n";
$email_message .= "Content-Type: {$fileatt_type}; name=\"{$files_array[$a]}\"\n";
$email_message .= "Content-Disposition: attachment; filename=\"{$files_array[$a]}\"\n";
$email_message .= "Content-Transfer-Encoding: base64\n\n";
$email_message .= $data . "\n\n";

$email_message .="--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);
if ($files != ""){for ($a = 0; $a <$no_files; $a++) {unlink("files/".$files_array[$a]);};};

There are 3 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.

Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.