Home > php > Add email attachments by URL in CodeIgniter

Add email attachments by URL in CodeIgniter

December 24Hits:15

I tried this code to attach a file in CI. This is working:

$this->load->library('email'); $this->email->from([email protected]', 'vignesh'); $this->email->subject('Email Test with attachment'); $this->email->message('Testing the email class IN CODEIGNITER'); $this->email->attach('/path/to/attachment1.jpg'); $this->email->send(); 

But I want to attach a file from an external URL:



No, it isn't possible, you'll need to download the file first. Using Phil Sturgeon's cURL library for CodeIgniter you should be able to get the file

$img = $this->curl->simple_get('http://mydomain.in/path/to/attachment1.jpg');
$filename = basename($img);
write_file("./upload/path/" . $filename, $img);

and then include it


You could later build in caching to check if the file was already downloaded / exists so it doesn't need to fetch it again.

Related Articles

  • Add email attachments by URL in CodeIgniter December 24

    I tried this code to attach a file in CI. This is working: $this->load->library('email'); $this->email->from([email protected]', 'vignesh'); $this->email->subject('Email Test with attachment'); $this->email->message('Testing the email

  • How to add multiple attachments to an email template?April 15

    I'm creating a UI that feeds into an email template via visualforce. One of the features I want to add is the user should be able to click checkboxes and add attachments to an email template. When the user clicks a button to get to the constructed em

  • Popup to allow emailing of current URLSeptember 29

    I'd like to implement an email icon on the pages of our SharePoint 2010 site collection; when the user clicks it, a Lightbox-style popup allows the user to email the current URL with a custom message to someone. It would be great to have fields for t

  • Exchange 2003 Strip Email Attachments save to User fileJanuary 12

    I'm currently using this vba script (locally on client) to strip email attachments from user's folder to and move to user document folder and then replace with a pointer in the email to reference the attachment. Public Sub SaveOLFolderAttachments() D

  • how to add multiple attachments to only one ListItemApril 11

    This code creates a new listitem for every attachment but i only want to create 1 listitem and add all attachments to it SPList myEmployeeDocList = web.Lists.TryGetList("Document cv"); if (myEmployeeDocList != null) { SPListItem employeeDocListI

  • Can a firewall tamper with email attachments?May 9

    I am using Thunderbird as an email client for managing my different email accounts. Yesterday my friend sent me an email with a PDF attachment. Today when I tried to open the attachment I get the following error popping up: This attachment appears to

  • Inbound Email AttachmentsFebruary 22

    I have a requirement where in i need to store the attachments in the emails received to notes&attachments section in salesforce for a particular object record automatically.Is that possible? --------------Solutions------------- Here are few steps whi

  • Can someone know my IP address through Thunderbird email attachments?June 27

    Can someone know my IP address through Thunderbird email attachments? Can a cunning attacker manage to find my IP address through attachment 'images' in emails that I unsuspectingly open? --------------Solutions------------- It depends. Assumption: b

  • Mail Drop "Add Email" Button on MacNovember 30

    I have apple computer. When I use the mail drop "add email" button to salesforce, it pastes in with this in the beginning (at least half of the time). Are we able to remove this? v:* {behavior:url(#default#VML);} o:* {behavior:url(#default#VML);

  • how to add email to domain I purchased from godaddyMarch 25

    I just purchased a domain from godaddy. However, I did not buy email from them. Is there a way to add email to my domain? for example [email protected]? I was going through this google apps link but I still don't understand how I can create email

  • Configure Sharepoint Server site to send email attachmentsJanuary 26

    We want to use Sharepoint to send attachments to secure users email group. Basically sending attachment once if verified metadata that will indicate which email user group needs to receive the attachment. Can Sharepoint send email attachments to user

  • add email account to postfix for user not existent on machineJune 7

    Postfix seems that uses the system users to define email accounts, i'm wondering if there is an alternate method to create accounts? i want to add email users that do not belong to the system and cannot shell to the server thanks --------------Soluti

  • Add-on for automatic URL shortening in browserJune 17

    Are there any plugins or third party apps/add-ons/extensions in Firefox, Chrome, or any other browser which shortens copied URLs on the go? --------------Solutions------------- You could try the bookmarlet for bit.ly (a URL shortening service): https

  • How can I drag and drop email attachments in Mail on Lion?

    How can I drag and drop email attachments in Mail on Lion?October 26

    I use Mail.app on Lion with Classic View enabled so it works like it did in Snow Leopard. When an email comes in with an attachment, I used to be able to select one or more attachments and drag them to my desktop. In Lion, it looks like I have to cli

  • How can I download email attachments only when requested?October 29

    The default email application seems to be downloading email attachments when I try to read an email. I don't want to download attachment by default, it should on request. I should be able to read the mail body text without needing to download the att

  • How to add emails (but not users) to Google Apps shared Directory, preferrably by importDecember 11

    I have a Google Apps (free) account. I wish to add email and other contact information to the (shared) directory. How do I do this one at a time? Right now the directory just has the users' emails. Is there a way to import vCards or other format for

  • Can I use Node to add email functionality to an existing site?February 2

    I have a client with an existing straight up HTML/JavaScript site. No back end of any kind. He wants to add email functionality to it and I was thinking of using Node to do this for two reasons: It seems like an extremely lightweight way to do it He'

  • Contextual Links add destination=node to URL - can i restrict that from happening? - stopping delete functionalityMarch 6

    I have a contextual link on a block that will take the user to an admin screen with a delete button on the admin screen. The delete button works fine when not coming from the contextual link. I noticed the contextual link adds "destination=node"

  • Open Source tool to block email attachmentsApril 24

    Is there any way to stop users from sending attachments over Gmail or any web based email including private mail servers, if internet access is through a Linux box running Ip Tables/Squid etc. We are looking for a free/open source tool. Can this be a

  • Postfix - how to add emails to the queue without being delivered?May 22

    I have a quick question. How does one add emails to Postfix's queue without it delivering the emails? I am writing a script to email Postfix statistics (queue count, sent, etc) to our support staff. I want to test it when there are emails in Postfix'

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.653 s.