StartVM Posted January 6, 2015 Report Share Posted January 6, 2015 Hello, How would I go about adding an attachment such as a .zip file to my registration accepted email template? Thanks Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted January 6, 2015 Moderators Report Share Posted January 6, 2015 There's some pointers here, you don't want to really be sending large attachment files to people. Try to keep it under 15-20MB as possible, depending on email providers limitations on attachments. Better option if you don't want to edit the core files of phpVMS, upload the attachment in your site files, and add a link in the email. (Recommended) But if you want to actually send attachments and knowing the risks of modifying core files, then follow along below... THIS REQUIRES MODIFYING CORE FILES. BACK UP BEFORE YOU MAKE CHANGES. TAKE NOTE, WHEN YOU UPDATE PHPVMS, THIS OVERWRITES! IF YOU UPDATED YOUR PHPVMS, YOU WILL HAVE TO REDO IT. Fortunately, phpVMS has a Mailer class that allows to send attachments, we'll have to make some changes here... 1) Go to /core/lib/phpmailer/class.phpmailer.php and find this line... (around line 232) public static function SendEmail($email, $subject, $message, $fromname='', $fromemail='') Replace with this... public static function SendEmail($email, $subject, $message, $fromname='', $fromemail='', $attachment='') 2) In the same file still, find the following lines... (around lines 294-296) $mail->AddAddress($email); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $alt; Add after the following lines... if($attachment != '') { //We need to define the root, otherwise once this runs, it will start looking in the wrong place from here. $mail->AddAttachment(SITE_ROOT.'/'.$attachment); } 3) Save the file. 4) Go to /admin/modules/PilotAdmin/PilotAdmin.php and find this line... (around line 646) Util::SendEmail($pilot->email, $subject, $message); Now here's what I need to explain to you. If you were to upload the welcome.zip file onto your website files, like say if you put it in your root folder along with folders named (admin, core, lib...ETC.) You would update the following lines as above... to this...(note the additional three parameters, the first one is the From Name, and the second one is the From Email Address, and the third one is the location of the attachment) Util::SendEmail($pilot->email, $subject, $message, '', '', 'welcome.zip'); But if you wanted to put the attachment, welcome.zip in a folder called new_pilots in your root along with the folders named (admin, core, lib...ETC.), then the lines would be appropriate... Util::SendEmail($pilot->email, $subject, $message, '', '', 'new_pilots/welcome.zip'); I hope this works, but this isn't tested yet, but I believe this will work. Let me know how you make out! Cheers! Quote Link to comment Share on other sites More sharing options...
StartVM Posted January 6, 2015 Author Report Share Posted January 6, 2015 There's some pointers here, you don't want to really be sending large attachment files to people. Try to keep it under 15-20MB as possible, depending on email providers limitations on attachments. Better option if you don't want to edit the core files of phpVMS, upload the attachment in your site files, and add a link in the email. (Recommended) But if you want to actually send attachments and knowing the risks of modifying core files, then follow along below... THIS REQUIRES MODIFYING CORE FILES. BACK UP BEFORE YOU MAKE CHANGES. TAKE NOTE, WHEN YOU UPDATE PHPVMS, THIS OVERWRITES! IF YOU UPDATED YOUR PHPVMS, YOU WILL HAVE TO REDO IT. Fortunately, phpVMS has a Mailer class that allows to send attachments, we'll have to make some changes here... 1) Go to /core/lib/phpmailer/class.phpmailer.php and find this line... (around line 232) public static function SendEmail($email, $subject, $message, $fromname='', $fromemail='') Replace with this... public static function SendEmail($email, $subject, $message, $fromname='', $fromemail='', $attachment='') 2) In the same file still, find the following lines... (around lines 294-296) $mail->AddAddress($email); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = $alt; Add after the following lines... if($attachment != '') { //We need to define the root, otherwise once this runs, it will start looking in the wrong place from here. $mail->AddAttachment(SITE_ROOT.'/'.$attachment); } 3) Save the file. 4) Go to /admin/modules/PilotAdmin/PilotAdmin.php and find this line... (around line 646) Util::SendEmail($pilot->email, $subject, $message); Now here's what I need to explain to you. If you were to upload the welcome.zip file onto your website files, like say if you put it in your root folder along with folders named (admin, core, lib...ETC.) You would update the following lines as above... to this...(note the additional three parameters, the first one is the From Name, and the second one is the From Email Address, and the third one is the location of the attachment) Util::SendEmail($pilot->email, $subject, $message, '', '', 'welcome.zip'); But if you wanted to put the attachment, welcome.zip in a folder called new_pilots in your root along with the folders named (admin, core, lib...ETC.), then the lines would be appropriate... Util::SendEmail($pilot->email, $subject, $message, '', '', 'new_pilots/welcome.zip'); I hope this works, but this isn't tested yet, but I believe this will work. Let me know how you make out! Cheers! Thank you so much for your effort. My question, is it doesn't seem that this attachment will only be included in the registration accepted email. Seems like it would include itself in all emails. Quote Link to comment Share on other sites More sharing options...
Tom Posted January 6, 2015 Report Share Posted January 6, 2015 Thank you so much for your effort. My question, is it doesn't seem that this attachment will only be included in the registration accepted email. Seems like it would include itself in all emails. That's what this bit is in there for: if($attachment != '') { //We need to define the root, otherwise once this runs, it will start looking in the wrong place from here. $mail->AddAttachment(SITE_ROOT.'/'.$attachment); } If you don't want to send an attachment, don't specify an attachment. 1 Quote Link to comment 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.