USD Logo MySanDiego | Libraries | Torero Store | Find People | A to Z Index | Resources | Jobs
 Prospective Students | Current Students | Alumni, Parents & Friends | Faculty & Employees | Visitors | International
About USDAdmissionsAcademicsNews and EventsAdministrationAthleticsGiving

Attachments

Attachments

Remember that as soon as you start attaching things to your mail, you increase the risk that they’ll be quarantined by spam filters. Also, the prohibition against sending e-mails to addresses pulled in from a form apply double to attachments. Do not ever send an attachment to anyone whose address you’ve taken from a form.

Attaching variables

The plug-in can add textual attachments to your message. For example, if you want to attach CSV data, you can do so.

$message->attach($cities, 'cities.csv');

This example assumes that $cities is a string of text; the recipient will be able to download the attachment as “cities.csv”.

Attaching existing files

If you have a file that you need to send to people who have submitted a form, you can use the $message->attachFile() method.

$message->attachFile("/path/to/file");

The method will determine the file name and the mime type from the filename.

Attaching uploaded files

If your form is accepting uploads and you’d like the uploads e-mailed to you, you can use the attachUpload() method.

$message->attachUpload("fieldname");

The “fieldname” is the name you used for the file upload field in the form. If a file was uploaded via that form item, it will be attached to the e-mail.