Jump to content


Photo

Using phpmailer - File attachment problem


  • Please log in to reply
3 replies to this topic

#1 Connexion

Connexion
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 03:11 PM

Hello,

I have been working on this for a couple days on and off and have tried to find my problem but havent been able to figure it out.

I am getting the email with a jpg attachment but cant open it, it gives me an error CANNOT DETERMINE FILE TYPE.

Any help would be apreciated.
Thanks

$image_part = $Tech."_".$FirstName."_".$LastName."_".$CompletionDate."_".$HTTP_POST_FILES['Pic1']['name'];
$image_list[0] = $image_part;

require("phpmailer/class.phpmailer.php");

$mail = new PHPMailer();

$mail->From     = "myaddress@connexioncomm.com";
$mail->FromName = $From;
$mail->Subject = $FirstName." ".$LastName;
$mail->Host     = "mail.jobtrackonline.com";
$mail->Mailer   = "sendmail";

    // HTML body
    $body  = "Hello <font size=\"4\">" . "</font>, <p>";
    $body .= "Photos have been uploaded for ".$FirstName." ".$LastName."<p>";
    $body .= "Sincerely, <br>";
    $body .= "Connexion Communications, LLC";

    $mail->Body    = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress("myaddress@charter.net", "John Doe");
    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/".$image_list[0],$image_list[0]");

    if(!$mail->Send())
        echo "There has been a mail error sending to " . $row["email"] . "<br>";

    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments();



#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 27 September 2006 - 03:23 PM

I've never used phpMailer before, but the below line doesn't look right to me.

    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/".$image_list[0],$image_list[0]");

You could try:
    $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]");

Also, I know that AddAttachment returns false if it can't find or access the file, if AddStringAttachment does, you could try something like this:

<?php
$attachtest = $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]");
if ($attachtest == false){
   echo "Didn't like this line\n";
}
?>

Anyway, like I said, these are only suggestions as I've never used the class before.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Connexion

Connexion
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 08:07 PM

Well you were pretty close. Thank You for the help HuggieBear.

Here is what I ended up with.

<?php
$attachtest = $mail->AddAttachment("/jobphotos/{$image_list[0]}", "$image_list[0]");
if ($attachtest == false){
   echo "Didn't like this line\n";
}
?>



#4 winnie

winnie
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 October 2006 - 02:27 AM

Hello,

I have some problem with attachment file by using phpmailer too, but my problem is the size of the file.
when attached file size is under 100KB, it's work well but when the attached file size over 100KB it's not work (mail does not send).

Can anyone tell me why?
Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users