13, February 2012

Problem with Attachment Mailer Class - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Problem with Attachment Mailer Class
« previous next »
Pages: [1] Print

Author Topic: Problem with Attachment Mailer Class  (Read 2125 times)
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« on: Sep 24, 2007, 10:39:51 pm »

Hi all, I am having a small problem with the mailer class and was hoping someon could assist me. the problem seems to be with the line:

Code:
$emailsend->html_body = $html_body;

With the line above, if I send the email then the text in the email shows as htm just the wa I want, but NO attachments come through at all.  If I change the line to the following:

Code:
$emailsend->text_body = $html_body;

Now the email is sent with attachments, but obviously the text is in plain text format. Here is the code I am using:
Code:
// MUST HAVE READ OR UPDATE PERMS TO SEND VIA EMAIL
if($do=='send')
{
$res2 = mysql_query("select * from new_staff where username='$_user'") or die(mysql_error());
$row2=mysql_fetch_assoc($res2);
$emailsender=$row2[email];
$emailsendername=$row2[first_name] ." " .$row2[last_name];
$emailsend = new attach_mailer($name = "$emailsendername", $from = "$emailsender", $to = "$emailto", $cc = "", $bcc = "", $subject = "$emailsubject");
$html_body="<HTML><BODY><p><b>$item_intro</b></p><p>$item_main</p>";

//FOR EACH ITEM FILE ADD AS ATTACHMENT


$res3 = mysql_query("select new_file.file_id, new_file.item_id, new_file.name, new_file.location, new_file.date_added, new_file.thumbnail, new_file_type.application, new_file_type.icon, new_staff.staff_id, new_staff.first_name, new_staff.last_name FROM new_file, new_file_type, new_staff where new_file.file_type=new_file_type.file_type and new_file.added_by=new_staff.staff_id and new_file.item_id='$id' and new_file.active='yes' ORDER by new_file.date_added DESC") or die(mysql_error());
if(mysql_num_rows($res3)>0)
{
$html_body = $html_body ."<BR><b>Please find the following files attached to this message:</b><BR>";
$html_body = $html_body ."<ul>";
for($i=0;$i<mysql_num_rows($res3);$i++)
{
$row3=mysql_fetch_assoc($res3);
$link= "uploaded_files/" .$row3[location] ;
//$filedate = $row[date_added];
//$filesize = round((filesize($link)/ 1024),2);
//echo "<tr><td width='32' align='center'><IMG SRC='$icon' ALT=''></td><td><a href='$link' target='_blank'><b>$row[name]</b></a> [$filesize KB]</td><td width='90'>$filedate</td><td width='130'><a href='user_info.php?id=$row[staff_id]'><i>$row[first_name] $row[last_name]</i></a></td><td width='25'>";
      //echo "<a href='request_deletion.php?id=$row[file_id]&type=file' onmouseover=\"roll('delete_$i', 'skins/$skin/delete24_2.png')\" onmouseout=\"roll('delete_$i', 'skins/$skin/delete24_1.png')\"><IMG src='skins/$skin/delete24_1.png' alt='Request Deletion of this File from Item' name='delete_$i'></a></td><tr>";
//$emailsend->add_attach_file("$link");
$emailsend->add_attach_file("$link" , $encoding = "base64", $dispo = "attachment", $type = "application/octet-stream");
$html_body = $html_body ."<li>$row3[location] </li>";
}
$html_body = $html_body ."</ul>";
}
$html_body = $html_body ."</BODY></HTML>";
$emailsend->html_body = $html_body;
//$emailsend->text_body = strip_tags($emailsend->html_body, "<a>");



//SEND EMAIL
$emailsend->process_mail();
echo $emailsend->get_msg_str();
echo "<p align='center'><input type='button' class='button' value='Finished' STYLE='width: 150px' onclick='done(\"item_detail.php?id=$id\")'></p>";
}

Any ideas where I am going wrong?

Thanks in advance,
Scott Thompson
« Last Edit: Sep 25, 2007, 12:40:18 am by kotik »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Sep 25, 2007, 12:16:16 am »

Hi,

maybe the path from the file is not valid? and you need to create a new object for each email, otherwise you need to the mail to all people at the same time.


Last blog : A new Wordpress theme for our blog
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« Reply #2 on: Sep 25, 2007, 12:43:59 am »

Hi,

maybe the path from the file is not valid? and you need to create a new object for each email, otherwise you need to the mail to all people at the same time.

hi, thanks for the reply. The path to the file is OK as it works with
Code:
$emailsend->text_body = $html_body;
but not with
Code:
$emailsend->html_body = $html_body;

I am only sending the email to one person but attaching html content from a database as the body of the email and also attaching several files (I am grabbing the location from the database also).

Thanks.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Sep 25, 2007, 10:16:48 am »

try the example again, I'm sure that the path is the problem (test it with file_exist)


Last blog : A new Wordpress theme for our blog
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« Reply #4 on: Sep 26, 2007, 04:29:02 am »

file_exists returns 1 for all files so the link is fine. It also works with the example but I need the script to work with custom dynamic database HTML content. Can I do this kind of thing:

Code:
$html_body="<HTML><BODY><p><b>$item_intro</b></p><p>$item_main</p>";

and then this to send:

Code:
$html_body = $html_body ."</BODY></HTML>";
$emailsend->html_body = $html_body;

I am a bit lost as to what I am doing differently other than using dynamic HTML instead of reading in an HTML document.

I appreciate your assitance with this.

Thanks.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Sep 26, 2007, 08:33:29 pm »

should work, I use it often this way


Last blog : A new Wordpress theme for our blog
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7153
Tags : attachment Mailer class email Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Problem with Attachment Mailer Class
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb 13, 2012, 07:10:11 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.