Jump to content

Archived

This topic is now archived and is closed to further replies.

Connexion

Using phpmailer - File attachment problem

Recommended Posts

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

[code]
$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();

[/code]

Share this post


Link to post
Share on other sites
I've never used phpMailer before, but the below line doesn't look right to me.

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

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

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:

[code]
<?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";
}
?>
[/code]

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

Regards
Huggie

Share this post


Link to post
Share on other sites
Well you were pretty close. Thank You for the help HuggieBear.

Here is what I ended up with.

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

[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.