Topic: Problem with Attachment Mailer Class (Read 1503 times)
I crack Photoshop!
Posts: 3
22 credits Members referred : 0
« on: Sep 24, 2007, 11: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>");
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6690
34708 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Sep 25, 2007, 01: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.
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:
Posts: 6690
34708 credits Members referred : 374
It's time to use PHP5!
« Reply #3 on: Sep 25, 2007, 11:16:48 am »
try the example again, I'm sure that the path is the problem (test it with file_exist)
I crack Photoshop!
Posts: 3
22 credits Members referred : 0
« Reply #4 on: Sep 26, 2007, 05: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: