Jump to content

Adding Attachment in email_registationaccepted.php


StartVM

Recommended Posts

  • Moderators

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...