Hi Guys I am just this curious, I wonder if PHP can do this stuff:
I have an anchor tag that says "send email to admin".
What I want to do is to open a default email client such ms outlook or lotus and automatically create an empty mail message.
I only want PHP to do it. Is it possible?
If it may, how should I do it?
Use HTML - the browser will handle it.
Click me
PHP only runs on the webserver, it has no access to the programs on a client-computer.
I think you want to use mailto
Fritz Eierschale, fritz.eierschale#example.org
What you describe is possible, though not directly by means pf php:
If I got you right, then you want to offer sending such an email on a web page created by means of php. If so, then all you have to do is use a "mailto" reference. The clients environment will decide what application to open to use that link:
Send email to admin
Note however that this only works, if there is a local email client installed and configured at all on the client side. More and more users use web based email applications instead of a local client, with all the disadvantages. In such case the clients system will popup an error about no suitable application available...
Related
I tried to search for this problem, but there are alway things like "i don't recomment to use E-Mail for that", and then there are other solutions. So, I'm here and ask u:
I need a way to upload/generate files(.html/.php) on my Website via E-Mail. And it realy need to be E-Mail, because E-Mail will be the only possible way for me to communicate(google: winlink) with the internet in the next month/year.
But I have no idea how i could do this. I'm looking here for some ideas/ways/tipps for what i should look, or better a good and ready solution.
It should be possible to send a E-Mail with a text, and this needs to be placed in a .html or .php file on my webspace. And good would be, if I'm able to give the name of the file ... and then replace or generate it.
I hope there is a solution in php ... but if sql is necessary it ok too(I'm going to learn it next, too).
MfG Torben
If you have the opportunity to setup a mail server, you can handle stuff like this with some effort with sieve (depending on subject, content or from address) and dovecot. Here's a tutorial in german for setting up a mail server: Mail-Server
Once setup, you can write a program which is called by sieve and is running the code required for what you desire. Please note carefully that this will never be
a) save
b) failure prove
If you can live with those side effects, feel free to go with it!
SIDENOTE:
Better solution might be: Wherever you have access to the internet, you can access the internet and your site/server to.
For the WinLink and Sailmail community, SailBlog offers a blog web space, which is editable via E-Mail. This feature is integrated to the GUI of Airmail (WinLink client for PACTOR, Telnet, Packet and also WINMOR using BPQ32 TCP/IP virtual serial port emulation). Sadly, the Post By Email feature requires an Premium Basic account.
But what about setting up a new E-Mail account, looking for a Perl or PHP library that can handle E-Mail and MIME attachments and running a script on your server, which checks for new E-Mails (new Upload files, directory listing request, Upload files etc.)
This tutorial teaches you how to create a contact form for a website using php script: http://www.boutell.com/newfaq/creating/email.html
But how does this work? How does the script access the user's email account to send an email? How does such a form work without a server? (For example if I put my website on github pages which only handles static pages, how does this php script work?)
there's no way to make the server do something if the server does only throw HTML pages out.
You need some programming language (PHP in your tutorial) to process your code, it has to be installed in the server and accessible to you. It will run your code, decide what to do and do it (by the way to actually send the mail you will need the proper PHP modules available). In this case the script will not use the user's email account to send the mail: it is the server who sends the mail, not the user's client. You will receive an email from your server, so watch out to ask the user for his email, otherwise you will not be able to get it in any way.
If you have no serverside intelligence capacity, just use your user's tools. Which means stuck with the mailto scheme (as the tutorial's first examples show). Then the user's computer will send the email (with the drawbacks the tutorial points out)
It uses the mailto: URI scheme which is opened by your mail client just like skype: scheme is bounded to your Skype client.
I have an e-mail address that is signed up to a list-serv and I would like to set up a script to monitor it. If it gets an e-mail addressed to the list-serv, I would like to have the contents dumped to a secure webpage a user would log into (in a blog-style output, making it almost like one big thread for a forum) so that all of the e-mails are in a central location.
I'm pretty sure php has this type of capability, but I'm new to web dev so was wondering if someone could point me in the right direction of how I could go about this.
If you email provider supports IMAP you can use PHP IMAP functions to do this.
I'm working on shifting my local web application to google apps. I have an account already for google apps for business and right now I need to work on the functionality of interacting with email.
Let me give a synopsis - my web app currently was set up that a cron job would download all emails from a set mailbox into a database at short intervals and when each message would be entered they would be assigned a specific ID and we would be able to use that ID to refer to that message in our application wherever we would require. So basically our applications mail section gave the illusion of being a webmail client when nifact it would retrieve from a database. I'm interested in a solution with google apps on a similar case.
The thing is that the application initially when the cron job runs - not only does it download a the email from the mailserver but it would also delete the email from the mailbox. So basically we would refer to the email on our local database as that is where it would exist.
Now however I don't want to delete the email form the inbox at all. Infact I would like to set it up such that I can maintain a reference to an email on my gmail inbox and still have a copy in my local system or at the least a basic link to the email. The thing is that from my programming with email webclients I havent been able to find what is a UNIQUE ID for emails in the mailbox which could be used as a way to identify them from an external application - emails seemed to be numbered by sequence and the sequence changes when an email is moved between inboxes. The UID or unique ID value seems misleading as it is just a sequence number for that email which can change if earlier emails are deleted or moved about.
What would be the best way to do this?
Are you sure about the fact that the id changes? I just archived a message that was in my inbox. (I had copied the link beforehand). Then I took the link, and used it in a completely different browser (first time was FF, second time was Chrome). It pulled up the same e-mail.
Google's IMAP server supports a proprietary X-GM-MSGID command which allows retrieval of a message's Gmail UID.
https://developers.google.com/google-apps/gmail/imap_extensions#access_to_the_gmail_unique_message_id_x-gm-msgid
I have set up an email id my PHP web application. Users will send emails to this id.
I want to process these emails in the application. Ho do I go about doing this?
Thanks in advance.
I recently worked on a project that required parsing of email from gmail and updating database with certain values based on the contents of the email. I used the ezcMail (now) Zeta Components library to connect to the mail server and parse the emails.
The strategy I adopted was to filter all interesting incoming mail with a label "unprocessed". Run the PHP script via a crontab every 15 minutes. The script would connect to the mail server and open the IMAP unprocessed folder and parse each email. After inserting the interesting values into the database, the script moves the files to another IMAP folder "Proccessed".
I also found IMAP to be better than POP for this sort of processing.
Recently I wanted to be able to receive emails immediately in something I was making so I did some research (I came looking on this question here too actually) and I ended up finding Google App Engine to be pretty helpful. It has an api you can use to receive and process emails sent to ____#yourapp.appspotmail.com. I know that it doesn't really seem helpful since you probably don't want your app on App Engine and you want to receive emails at yourdomain.tld, but with a little setup you can get what you want.
My basic setup is like this:
User sends email to user_id#mydomain.tld (an email address that doesn't actually exist)
mydomain.tld has a catchall email address that forwards to inbox#GAEapp.appspotmail.com
GAEapp (a tiny app on app engine) receives the email, processes it out, and sends a post request with relevant stuff to mydomain.tld
So basically you can make a little GAE app that works like a go between to grab the emails. Even with the redirect it'll work out ok, the email will be fine.
Also I decided to learn me some django and I made a free app called Emailization that will basically do that for you. You create a recipient like ___#emailization.com and give a URL to POST to. Anything sent to that address gets POSTed to you URL. You can make a catchall on your domain that forwards to that emailization recipient and you'll get email through the catchall too!
or you can see a small GAE app I made that you can setup yourself that does the same thing.
Hope that helps somebody!
Use procmail if it is installed on your system. Put these lines in a .procmailrc file in the home directory of the user who receives the e-mail.
:0
| /path/to/your/script.php
Or you can also use a .forward file containing
"|/path/to/your/script.php"
Procmail has the advantage that it allows you to deal with more complicated filtering if your application ever requires it.
Your script.php file will read the headers and body of the e-mail from stdin.
Check out fMailbox. It does not require any non-standard extensions (such as imap) and has been tested with various servers, attachments, multipart messages, SSL, and more.
I suggest using Zend_Mail component of Zend Framework.
There is a great library: Try this: http://code.google.com/p/php-imap
You need to implement an email client in Php. This is probably going to be a POP client.
This code would query the POP server containing your email, download it, and then you could parse it as needed.
A quick google search of "POP client php" has revealed a vast array of different options. Its hard to tell if there's really "The One True PHP POP Library", otherwise I'd include it here. If you are using a preexisting framework, you may wish to check to see its level of POP support, otherwise check the google results above and take your pick. Or it may just be easiest (and most educational :) ) to roll your own.
There are a number of hosted solutions that will accept email for your domain and then post it a script on your website. Most of these will handle the parsing of the messages for you (separating the attachments, "to" "from" and other addresses, etc).
You just create a script that receives a FORM POST and does whatever you need with it.
Mailgun
CloudMailin
You can also look at Mandrill (by MailChimp), SendGrid, and PostMarkApp.
Hosted solutions as Travis Austin suggested work well.
If you are looking for a self-hosted one, you can have a look at the Mailin module allows you to receive emails, parse them and post them to a webhook of your choice.It also checks the dkim and spf, computes a spamassassin score and determines the message language.
I don't know if it will suit your needs since it is written in node.js, but the more options you have, the better. (Disclaimer: I am the maintainer of Mailin)
There is a great tutorial for this here:
http://www.evolt.org/incoming_mail_and_php
which covers how to have the emails forwarded directly to your script, which your script reads via stdin (fopen, fread, etc.) The tutorial code even does basic parsing of the header/body for you.
If you want to avoid reaching out over POP or IMAP to another server to pull-down the email, you can add a 'hook' into the email receive process on some SMTP server you set up (possibly the same php server). Then just have the destination email handled by this server.
Here is an example with postfix, but similar things are possible with sendmail as well.
http://www.adkap.com/autoresponder.html