Function that gets mail in PHP - php

Is it possible to write in php such a script that will connect to a mail server like gmail.com and get a mail from it ?
Maybe it sounds naive, but maybe there is a function that will do that ?

There's the IMAP library in PHP.
A quick Google search gave me an example of how to use it.

Yes there is,
Please look into IMAP
http://www.php.net/manual/en/book.imap.php

Related

How to access mail from gmail

I was using imap functions in my app to access gmail. Unforunately I have not been able to use imap any more. I am using php. Is there any alternative way like (api..) to access gmail.
I appreciate any help.
In short, no. The only GMail API which provides access to mail is the IMAP one.
You don't explain why you can't use imap any more, but that's ok.
You can use php imap extension to connect with pop3!
Here is an example.
Try Zend Framework:
Code is Here
http://framework.zend.com/manual/en/zend.mail.read.html

How can I send mail with PHP's mail() function and MAMP Pro?

I'm developing a website that will utilize PHP's mail() function. I'm running MAMP Pro (primarily because it has the Postfix feature that is supposed to be useful for sending emails). I feel like I've tried everything, but my program still won't send emails. It doesn't even really matter to me that I use mail(). I just want to be able to send emails from my local MAMP Pro webserver so I can test out my website. Any suggestions would be greatly appreciated!
You need to set it up for your ISP.
http://documentation.mamp.info/en/mamp-pro/server/postfix
also
http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html
Other than that, I agree with the comments. What is your ISP? What is php telling you? Also, read your logfile for postfix and tell us what it says:
http://blog-en.mamp.info/2010/03/how-to-show-postfix-log-file-of-mamp.html

what is the exact code needed for a php to interact with an smtp server and send email? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Sending mass email using PHP
Does anyone out there know? I am trying to set up a php file to send data submitted in a form to a mysql database and also one of three email addresses (by means of an if statement). However, I am being told, I need to set up and manage an smtp server and also write code in my php file that connects with smtp server so that it will be possible for me to send email. However, I don't know how to do any of these things and if there is someone out there who does, would you mind helping me out? If so, I would greatly appreciate it.
I don't know if anybody is going to give you exact code, but I highly recommend the SwiftMailer library.
Read through the documentation a bit and try it out. It supports sending through your SMTP server instead of using the PHP mail() function.
If you are familiar with Zend framework, there is also a pretty advanced mail feature : Zend_Mail
Reading the PHP manual's page for mail() would be a good start
PHP doesn't actually send the mail. You need a mail server setup on a host machine that is listening for connections. Then in your code you can just use the mail command to actually send the email.

How to receive email and process it using PHP

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.

PHP Mail Client

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.

Categories