PHP mail() attachment problems

$to = “[email protected]”; $from = “Website <[email protected]>”; $subject = “Test Attachment Email”; $separator = md5(time()); // carriage return type (we use a PHP end of line constant) $eol = PHP_EOL; // attachment name $filename = “document.pdf”; //$pdfdoc is PDF generated by FPDF $attachment = chunk_split(base64_encode($pdfdoc)); // main header $headers = “From: “.$from.$eol; $headers .= “MIME-Version: … Read more

Downloading attachments to directory with IMAP in PHP, randomly works

This is perfect working answer, try this. This Sample run properly and download all the attachments with no issues. <?php set_time_limit(3000); /* connect to gmail with your credentials */ $hostname=”{imap.gmail.com:993/imap/ssl}INBOX”; $username=”YOUR_USERNAME”; $password = ‘YOUR_PASSWORD’; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to Gmail: ‘ . imap_last_error()); $emails = imap_search($inbox, ‘FROM “[email protected]”‘); … Read more

How to download the current page as a file / attachment using Javascript?

You can try with the protocol data:text/attachment Like in: <html> <head> <style> </style> </head> <body> <div id=”hello”> <span>world</span> </div> <script> (function(){ document.location = ‘data:text/attachment;,’ + //here is the trick document.getElementById(‘hello’).innerHTML; //document.documentElement.innerHTML; //To Download Entire Html Source })(); </script> </body> </html> Edit after shesek comment

Downloading multiple attachments using imaplib

For any future python travellers. Here is a class that downloads any attachment found for an email and saves it to a specific location. import email import imaplib import os class FetchEmail(): connection = None error = None def __init__(self, mail_server, username, password): self.connection = imaplib.IMAP4_SSL(mail_server) self.connection.login(username, password) self.connection.select(readonly=False) # so we can mark mails … Read more

Send PHP HTML mail with attachments

I tried Answer 1 for a couple of hours with no luck. I found a solution here: http://www.finalwebsites.com/forums/topic/php-e-mail-attachment-script Works like a charm- less than 5 min! You might want to change (like I did), the first content type from text/plain to text/html. Here is my slightly modified version to handle multiple attachments: function mail_attachment($files, $path, … Read more

add excel file attachment when sending python email

This is the code that worked for me- to send an email with an attachment in python #!/usr/bin/python import smtplib,ssl from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email.utils import formatdate from email import encoders def send_mail(send_from,send_to,subject,text,files,server,port,username=””,password=”,isTls=True): msg = MIMEMultipart() msg[‘From’] = send_from msg[‘To’] = send_to msg[‘Date’] = formatdate(localtime = … Read more

android exporting to csv and sending as email attachment

Thanks for everyone who tried to help..After taking a full day I have send an email from my app with attachment..This is the working code.. String columnString = “\”PersonName\”,\”Gender\”,\”Street1\”,\”postOffice\”,\”Age\””; String dataString = “\”” + currentUser.userName +”\”,\”” + currentUser.gender + “\”,\”” + currentUser.street1 + “\”,\”” + currentUser.postOFfice.toString()+ “\”,\”” + currentUser.age.toString() + “\””; String combinedString = columnString … Read more

How to create an email with embedded images that is compatible with the most mail clients

I’ve had success with exactly the same headers as you’re using, with the following differences: Embedded is not a valid value for the Content-Disposition header. attachment should be fine. inline should also be fine, though I’ve usually seen attachment for multipart/related embedded images. The value of the Content-ID header is supposed to be in the … Read more

PHP Attaching an image to an email

Try the PEAR Mail_Mime package, which can embed images for you. You need to use the addHTMLImage() method and pass a content id (cid), which is a unique string of text you will also use in your img’s src attribute as a cid: URL. For example: include(‘Mail.php’); include “Mail/mime.php”; $crlf = “\r\n”; $hdrs = array( … Read more