jaypotter Posted January 5, 2010 Share Posted January 5, 2010 I am using class.phpmailer.php. When I add an attachment to the email, the email gets sent with the attachment, but it is empty. When I go look at the file on the PC, it has data in it. has anyone had the problem before? Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/187296-emailed-attachments-are-empty/ Share on other sites More sharing options...
premiso Posted January 5, 2010 Share Posted January 5, 2010 Hard to help you without the code you are using to attempt to send the email. Quote Link to comment https://forums.phpfreaks.com/topic/187296-emailed-attachments-are-empty/#findComment-989078 Share on other sites More sharing options...
jaypotter Posted January 5, 2010 Author Share Posted January 5, 2010 Thanks for the quick reply. I use this code to call the function. share_email_send('jpotter@agne.com','Jay Potter','jpotter@agne.com','message','test','jpotter@agne.com',$t_reserves_path,'test.php') ; and here is the function code, which uses class.phpmailer.php. I hope class.phpmailer.php is a fairly standard class used throughout the PHP world. # -------------------- # This function sends an email message based on the supplied email data. function share_email_send($t_Recipient,$t_FromName,$t_FromAddress,$t_Message,$t_Subject,$t_Recipient2='jpotter@agne.com',$t_path = '',$t_attachment='') { global $g_phpMailer_smtp; $mail = new PHPMailer; $mail->From = $t_FromAddress ; $mail->Sender = $t_Recipient ; $mail->cc = 'jpotter@agne.com'; $mail->FromName = $t_FromName ; $mail->Subject = $t_Subject ; $mail->Body = $t_Message ; $mail->PluginDir = $t_phpmailer_path; $mail->Hostname = '127.0.0.1'; $mail->SetLanguage( 'en' ); $mail->IsHTML( false ); # set email format to plain text $mail->WordWrap = 80; # set word wrap to 50 characters $mail->Priority = '3' ; # Urgent = 1, Not Urgent = 5, Disable = 0 $mail->CharSet = 'utf-8'; $mail->Host = 'mail.agne.com'; $mail->AddAddress( $t_Recipient, '' ); $mail->AddAddress( $t_Recipient2, '' ); $t_Message = $t_Message . ' attachment ' . $t_attachment; if($t_attachment != ''){ $t_Message = $t_Message . ' tried attachment' ; $mail->AddAttachment($t_path, $t_attachment) ; $t_Message = $t_Message . $mail->ErrorInfo ; } $mail->Body = $t_Message ; # SMTP collection is always kept alive # $mail->SMTPKeepAlive = true; if( is_null( $g_phpMailer_smtp ) ) { # register_shutdown_function( 'email_smtp_close' ); } else { $mail->smtp = $g_phpMailer_smtp; } if ( !$mail->Send() ) { $t_success = false; } else { $t_success = true; } return $t_success; } Quote Link to comment https://forums.phpfreaks.com/topic/187296-emailed-attachments-are-empty/#findComment-989082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.