Jump to content


Using phpmailer - File attachment problem

  • Please log in to reply
3 replies to this topic

#1 Connexion

  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 September 2006 - 03:11 PM


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.

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


$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");

        echo "There has been a mail error sending to " . $row["email"] . "<br>";

    // Clear all addresses and attachments for next loop

#2 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.


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:

$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.

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

  • 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.

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

#4 winnie

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 October 2006 - 02:27 AM


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?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users