I know it is possible to send html enabled emails. Is it also possible to send PHP enabled emails?
For this to count:
php code has to be sent as plain text
php code has to be executed on some server X only after recipient opens the email
Server X is not the recipient's machine
If this is possible, what are the consequential security issues that this brings up?
You are basically trying to force the remote email client to display a remote HTML page (generated by PHP). No clients will do that, because it's a big security risk.
You could use AJAX, but all modern email clients will completely block any Javascript in the emails by default.
You can however request remote images. You could generate them on the fly (handle the jpg extension by PHP and generate the image on the fly), but that's very likely to kill your emails as spam by any spam filter. Most email clients will block remote images by default, but will usually show a button to unblock them (this does not happen for javascript scripts).
I think your best bet is sending HTML with an iFrame or you can try an Ajax call to get the HTML you want to inject (using javascript). I don't think you can just send PHP code embedded in the HTML.
Check example #4 http://php.net/manual/en/function.mail.php
This cannot be done in the way I think you are thinking. You cannot send PHP code and expect it to be interpreted by the email client.
However, you can link to an image, on your server, in the HTML email. And this image could be a PHP script which runs on your server. But most email clients do not display images by default for this very reason.
Related
I am sending email using mail() function in PHP.
I am using following code
send email
code to link email.
Aafter sending email using PHP , I have checked in mail and when I click on "send email" link it showing me following message
"Sorry, the page you requested was not found."
how can i use "mailto:" link in mail() function.
thanks in advance.
mailto:example#example.com and the php mail() function are to entirely different things, they are not even the same language, mailto is HTML and mail() is php. If you want to send an email to someone from your site you need:
The mail module installed on your server - get intouch with your hosting provider and ask.
The correct script to send the mail - for a simple email check w3schools? http://www.w3schools.com/php/php_mail.asp
If you want to open your clients email program use mailto as you have above.
mailto: links are handled by receiver's email client. If they are not working properly then it's on the 3 reasons:
1) Email client doesn't have that functionality or it's turned off.
2) Syntax errors in the HTML you send. This may be due to incorrect encoding or typo's in your server-side code when generating it (for ex. unclosed HTML tags or missing chars). Also check how your quote chars are encoded in href="".
3) Default email application is not set in your OS configuration. Usually this is set automatically when you install email client. On windows it's in Control Panel > Default Programs > Set program access and computer defaults. If there is no email client installed and you're viewing email from within your browser. Then check your browser settings. For ex. Firefox. (IE uses OS settings somewhere since version 9 or 10)
I have a strange requirement.
I need to read the outlook emails from a local pc using php .
I will get user credentials.
so is there any way to do this ?
it need to work well in all major browsers.
Thanks.
Not sure why you would want to try to get this from a LOCAL mail file on a 'single' pc, I would rather attack this from a POP3/IMAP route, it would THEN be a PHP based mail client, or whatever you need it for (fetching mail, filtering, checking, triggering an event, etc;).
But what you describe is just not feasible for anything, I can't see a client paying to have simple client mail accessed via PHP.
Here are some PHP / Email reading references:
http://garrettstjohn.com/entry/reading-emails-with-php/
http://davidwalsh.name/gmail-php-imap
http://www.tuxradar.com/practicalphp/15/6/3
I've just made some fixes to a web site that uses the Form2Mail PHP script. This worked on my home machine, a while back, but I have suddenly been pressured to release today, and it is already 3pm here.
I am an ASP.NET developer and know very little PHP, so if I have to improvise, writing my own version of the script is not a very feasible option. What other options to I have that can allow me to, out of the box, cause an HTML form's submit event to result in an email being sent to a configured email address?
sending mails in php is very simple http://php.net/manual/en/function.mail.php
you would just put a form that submits to something like mail.php, stick some mail code in there and you are done
I know you can send emails with PHP but, can you receive emails through PHP?
You can pipe incoming mails into a PHP script so you can process it directly. Evolt has an article on how to setup something like that. This can be useful if you want to activate scripts programmatically by sending Emails to it (like responses to a newsletter mail that unsubscribes the user).
If you just want to read mails using PHP, PHP has native functions to talk to IMAP, NNTP and POP mailboxes.
Take a look at http://cloudmailin.com it takes away a lot of the hassle involved with receiving the email and will send it directly to your app via an HTTP Post. We have quite a few php users using the system to receive email.
You could write a mail server in PHP that binds to a port and listens for incoming email.
But PHP is not the language I would recommend for tasks like this, and it would also be a hugely complex undertaking.
You can hook into an existing mail server as callback script, or periodically query a mail server via POP or IMAP. The latter option is the most common: run a PHP script that processes an email account via a cron task in intervals. See http://php.net/imap.
There is a great library that is based on IMAP extension: http://code.google.com/p/php-imap
Only a mail server can receive e-mails. You could read mail box formats (such as mbox or Maildir) to read e-mail using PHP.
PHP scripts functioning as IMAP/POP3 servers can receive e-mail sent to them.
What is the best way to parse email contents? For example, we want to be able to parse emails that are sent from 3rd parties and put them into a database. Right now we use Google Hosted accounts and we were thinking about maybe using PHP IMAP functionality to pull emails every couple minutes and parse their contents, putting it into our DB.
Wondering if that is overkill? If we sent the emails to a dedicated server would there be a way to grab and parse them with PHP?
Not sure how ticketing systems do it... put they allow you to create a ticket by sending an email to a specified address.
If you send the e-mails to a server, you can actually just set your forward file to pipe the e-mail to your parsing script by placing the following line in the .forward file of the e-mail account on the server:
| php createticketfromemail.php
That way you don't have to periodically poll, whenever an email arrives it will be piped to your script.
http://www.softpanorama.org/Mail/pipes_in_dot_forward_file.shtml
EDIT
To address the point that #miemos brought up in his answer. You can structure your forward file to both store a copy of the email in your inbox and pipe it to the script, that way if the script fails you will still have a backup copy of the email somewhere.
The safest way to receive and process messages using PHP is using a POP3 or IMAP mailbox. You can poll the mailbox regularly and process the messages and delete them afterwards.
Some systems allow you to pipe a message to a PHP script when the message arrives. This is not a safe way to process the messages because if for some reason your script fails you loose the message forever. Using a mailbox is safer because you can delete the messages after they are successfully processed.