I have a need to read the 'body' of the most recent email received using PHP (not interested in sender, etc...), but I am not at all sure how to do this. The mail server uses IMAP
http://ryerson.ca/ccs/email/rmail/clients/ConfiguringMozillaThunderbird.pdf <--Uses the same server described here. (This is not for my personal mail, its to read data and post it to a website. I would rather not use email to acheive this, but I do not have a choice here.)
Any idea how to do this? Code Examples? Anything is appreciated
The PHP IMAP Extension should provide you with what you need, assuming you have it or have the ability to install it.
Related
Once or twice a year i find myself in the position of having to develop complex emails.
They often include Plaintext and Html versions, along with attachments and other headers.
Previewing the development using standard send/receive is painfully slow and tedious.
What i'm looking for is a local testing platform that processes the mail function and provides a mail client style preview with access to alternate views, headers, etc. Or possibly a real mail client that can take mail directly.
I've searched and searched but no luck so far, hopefully someone can point me in the right direction.
Thanks in advance. TT
I'm not sure if this is what you want but you can use your localhost mail and access it via thunderbird for example
How do I read local email in thunderbird? - Ask Ubuntu
Via this way you don't have to wait endless for mail to be delivered as it's local. And you can see your send mail in a actual mail client
I don't know any software but I had some good experience with the following online service: http://litmus.com/ It's somewhat like browserstack. (live crossbrowser testing tool)
I use Papercut, which listens to a SMTP port, catchs all e-mails and shows headers, source, text and html view. It's very useful!
I have now solved this.
In the php.ini file there is an option to set an export path for the mail function called sendmail_path.
I set this to tee mail.eml > /dev/null and it now saves the sent mail to the same directory as where the function is called and i simply open it with my mail client.
sendmail_path = tee mail.eml > /dev/null
2 notes on this.
this is a solution for unix platforms only.
the file extension has to be set to suit your chosen mail client
For a task like this I use fakemail for receiving the mails into a maildir and mutt for reading the mails. Mutt can also be configured for reading HTML mails.
If you just want to log the emails without reading them, you could use the "logmail" approach described in this article by Chris Shiflett:
Edit: The lastcraft.com host seems to be down at the moment, my Google search for "fakemail" revealed this Python project that might be helpful: https://github.com/isotoma/FakeEmail
If you're just looking to preview your HTML emails (and alternatively, if you need help designing them) you can sign up for a free MailChimp account. It's actually an email send service, but they also have an interface for a drag-and-drop email builder.
For your situation, you could use the "code your own" tool, drop in your HTML, CSS, plain text, etc. and then preview the email in all sorts of email clients, test at different screen resolutions, etc.
(*I am not affiliated with MailChimp)
You can also try https://github.com/ycecube/phpmaildebug.
It uses the php's sendmail output to capture the mails.
I know there is plenty of PHP mail libraries out there, but most of them are designed to send emails, is there any library that will help me fetch emails from imap/pop3 accounts, deal with attachments etc?
I'm already using imap_* functions from PHP IMAP extension but using it is problematic, as I have to re-invent the wheel in most cases (ie. parsing the result of imap_fetchstructure to get to attachments)
Mayby there is any ready to use lib build on top of imap_* or similar, that will help me deal with fetching mails, without re-writing all that logic behind well known problems?
I have missed the obvious Zend_Mail will do the trick
Here is a PHP Pop3 Client that I use for a script on my server.
http://www.phpclasses.org/package/2-PHP-Access-to-e-mail-mailboxes-using-the-POP3-protocol.html
You could easily use that to create a graphical layout, but I have not had the necessity for it.
Can anyone suggest the methods I could use...
I m on shared hosting now (cpanel)... I have access to perl modules, ruby, (No idea how they work)
The IMAP extension is used for that. Either by having a real mailbox you check, or by letting the mailserver pipe emails to your your script & parsing the parts of the email with the provided funstions.
PEAR_Mail_MimeDecode class from Pear. Is the real solution.
Possible Duplicate:
Process RECEIVED email attatchment with PHP
If you are a on a shared hosting system it is possibly easiest to let someone like http://cloudmailin.com or http://smtp2web.com/ send the email to your app via a webhook.
You will then need to use something like Mail_MimeDecode to actually parse the message you receive and extract the content you want to use.
The past few days I've been trying to find out how I can save emails as drafts using php. I've created an emailaddress that uses imap (and resides on the same server).
What I would like to do is to use php to create an email and store it in the drafts folder. These emails would then be recognized by the email client (ms office outlook in this case) so they can be editted and send from the email client.
I've found some interesting information about the imap functions from php, they let you send mail, but I can't really figure out how to store them in the drafts folder (to which I have write access). I can actually find and read the emails, I save as drafts in my email client, using my ftp connection. However they make use of UID and message-ID's and such which I don't understand where they come from.
My questions:
- how could I create email drafts
- How does a new UID or message-ID get created, and how would I use them for my email-draft file?
Help is much appreciated, thanks.
Yorian
Have you checked if the proper extension is installed? To use the php imap functions the php5-imap extension must installed. You can check this by using phpinfo(). When there stands nothing about "imap", the extension is not installed.
Look into imap_setflag_full. there's a \draft flag.
AFAIK you can use imap_append() to store the mail in the INBOX.Draft mailbox (function.imap_append)
i am searching for a way to read mail messages from a PHP application, including access to attachments etc. imap functions are not acceptable as a solution, as this application will handle mails with heavy attachments.
i have full access to the server's mail folder from php via filesystem. any thoughts?
I think you could use a combo of the Pear packages Mail_Mbox and Mail_mimeDecode. Use Mail_Mbox to read new mail from the inbox, one message at a time, and use Mail_mimeDecode to extract the attachements. All this will be done w/o IMAP. You can then save the read messages to a different mbox to keep the inbox clean.
Pear - Mail_Mbox
Pear - Mail_MimeDecode
I had a question like this a while back. See if any of the answers help you:
How to get email and their attachments from PHP
postfix + maildrop was the solution I ended up taking, It routes the emails through to a PHP script when it arrives and in my case, the PHP does something with the attachment. But I only needed to read each email once. If you need to be able to browse all the emails, you either need to store the results of maildrop or find another solution.
If you need to full access to all emails, POP and IMAP are popular choices because they do work. I'm not sure why you're against them.