Node.js and Nodemailer: Can we attached PDF documents to emails?

Yes you can. You have to add the path of the file which you are trying to attach. transporter.sendMail({ from: ‘[email protected]’, to: ‘[email protected]’, subject: ‘An Attached File’, text: ‘Check out this attached pdf file’, attachments: [{ filename: ‘file.pdf’, path: ‘C:/Users/Username/Desktop/somefile.pdf’, contentType: ‘application/pdf’ }], function(err, info) { if (err) { console.error(err); } else { console.log(info); } … Read more

Sending mail attachment using Java

Working code, I have used Java Mail 1.4.7 jar import java.util.Properties; import javax.activation.*; import javax.mail.*; public class MailProjectClass { public static void main(String[] args) { final String username = “your.mail.id@gmail.com”; final String password = “your.password”; Properties props = new Properties(); props.put(“mail.smtp.auth”, true); props.put(“mail.smtp.starttls.enable”, true); props.put(“mail.smtp.host”, “smtp.gmail.com”); props.put(“mail.smtp.port”, “587”); Session session = Session.getInstance(props, new javax.mail.Authenticator() { … Read more

How to send an email with a file attachment in Android

Use the below code to send a file within a email. String filename=”contacts_sid.vcf”; File filelocation = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), filename); Uri path = Uri.fromFile(filelocation); Intent emailIntent = new Intent(Intent.ACTION_SEND); // set the type to ’email’ emailIntent .setType(“vnd.android.cursor.dir/email”); String to[] = {“asd@gmail.com”}; emailIntent .putExtra(Intent.EXTRA_EMAIL, to); // the attachment emailIntent .putExtra(Intent.EXTRA_STREAM, path); // the mail subject emailIntent .putExtra(Intent.EXTRA_SUBJECT, … Read more

Send File Attachment from Form Using phpMailer and PHP

Try: if (isset($_FILES[‘uploaded_file’]) && $_FILES[‘uploaded_file’][‘error’] == UPLOAD_ERR_OK ) { $mail->addAttachment($_FILES[‘uploaded_file’][‘tmp_name’], $_FILES[‘uploaded_file’][‘name’]); } A basic example attaching multiple file uploads can be found here. The function definition for addAttachment is: /** * Add an attachment from a path on the filesystem. * Never use a user-supplied path to a file! * Returns false if the file … Read more