FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Email to PHP





mikelll
I need to make a webpage in PHP language, that displays the content of an email in that page.
It will work like this:

I send an email to the server and then the server publishes the content of that email in that webpage!

Can anyone give me an idea how to start this?

Many thanks!
ankur209
That sounds a good idea...I think u'll have to use a ASP.Net support to it...!!

Don't know exactly about PHP... Crying or Very sad
But will ask my collegue over this... Wink
Fire Boar
ankur209 is wrong: it's entirely possible in PHP. A quick Google search should tell you how.
mikelll
Fire Boar wrote:
ankur209 is wrong: it's entirely possible in PHP. A quick Google search should tell you how.

Thanks but...Im not so dummy that you need to explain me how to use google!

I need help from those who simple want to help, and not from those who think thay are some kind of genious
badai
google will help you to get started. there are also a lot of ready made scripts out there. sure, you can start form scratch figure out everything on you own, but that's kind of hard if to teach you on forum like this. the only thing you should ask here is when you get stuck.

the way i see it, you don't even know how to begin, and someone really point you to the right direction.

i did click on the google link and the first result from phpclass website is probably something that you need. all you need to do is register there, download the script, and edit some lines.

can't you see he's trying to help you to get started? now say thank you, like your mother always taught you.


mikelll wrote:
Fire Boar wrote:
ankur209 is wrong: it's entirely possible in PHP. A quick Google search should tell you how.

Thanks but...Im not so dummy that you need to explain me how to use google!

I need help from those who simple want to help, and not from those who think thay are some kind of genious
mikelll
badai wrote:
google will help you to get started. there are also a lot of ready made scripts out there. sure, you can start form scratch figure out everything on you own, but that's kind of hard if to teach you on forum like this. the only thing you should ask here is when you get stuck.

the way i see it, you don't even know how to begin, and someone really point you to the right direction.

i did click on the google link and the first result from phpclass website is probably something that you need. all you need to do is register there, download the script, and edit some lines.

can't you see he's trying to help you to get started? now say thank you, like your mother always taught you.


mikelll wrote:
Fire Boar wrote:
ankur209 is wrong: it's entirely possible in PHP. A quick Google search should tell you how.

Thanks but...Im not so dummy that you need to explain me how to use google!

I need help from those who simple want to help, and not from those who think thay are some kind of genious


wrong ideia!
Who said that I don't know how to start? I know some php! Ineed to know if anyone knows a good class for this!
jmraker
I've done it in php. The things you'll need to consider
. Mime types, it's possible to get an email with the email message as text and as html
. Attachments, there's a few ways files can be attached like how they can be in <img> tags
. Encodings, there's 3 types of encodings, plain text, base64 and quoted printables. The email headers when encoded are done differently than the body.

http://us.php.net/quoted_printable_decode
http://us2.php.net/base64_decode

You can expect the code to be about 500 lines.
rjraaz
hmmmm it can be done through wordpress

just try wordpress and to its writing setting in admin there u got post via email

you can also extend it using plugins for category wise post or to assign different email id for different category
mikelll
jmraker wrote:
I've done it in php. The things you'll need to consider
. Mime types, it's possible to get an email with the email message as text and as html
. Attachments, there's a few ways files can be attached like how they can be in <img> tags
. Encodings, there's 3 types of encodings, plain text, base64 and quoted printables. The email headers when encoded are done differently than the body.

http://us.php.net/quoted_printable_decode
http://us2.php.net/base64_decode

You can expect the code to be about 500 lines.

thanks for the help! I will get my hands on the code and post here further developments
mikelll
rjraaz wrote:
hmmmm it can be done through wordpress

just try wordpress and to its writing setting in admin there u got post via email

you can also extend it using plugins for category wise post or to assign different email id for different category

I need to build it from scratch! Its a work I am doing for school
rjraaz
mikelll wrote:
rjraaz wrote:
hmmmm it can be done through wordpress

just try wordpress and to its writing setting in admin there u got post via email

you can also extend it using plugins for category wise post or to assign different email id for different category

I need to build it from scratch! Its a work I am doing for school


so try codeigniter or cakephp are good php framework to start.

or if u want to make fully from scratch then share your work (not your code) here if have any problem.

atleast we need to know how much section you done.

if u didnot started yet just lets go for it.

i will try to get from start.
Fire Boar
*sigh* Look, lmgtfy is a popular tongue-in-cheek way of saying "maybe you'd get ideas a little quicker if you did a search". It's not about being an unhelpful jerk with a "look how clever I am" twist. As badai pointed out, it's pretty hard to teach people from zero to working system. On the other hand, the first page of the search results for "php receive email" in Google has several useful tips and links and some fully-working systems.

General advice time. To get started, have a look at some of the things that people have done. Generally it involves connecting to a POP or IMAP server, sending the appropriate request and parsing the response. If you're doing this from scratch, you'd be well-advised to look up these two email protocols and find out exactly how they work.
Flakky
Does anyone know how to echo the entire email (incl. Headers)
I might be able to help if I understand how it's possible to do this.
rjraaz
Flakky wrote:
Does anyone know how to echo the entire email (incl. Headers)
I might be able to help if I understand how it's possible to do this.


if you are using imap then following link will be useful for you:

http://www.php.net/manual/en/function.imap-header.php

http://www.php.net/manual/en/function.imap-headerinfo.php

http://www.php.net/manual/en/function.imap-headers.php
thisdaddy
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>

</body>
</html>
rjraaz
thisdaddy wrote:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>

</body>
</html>


no this is just to sent email

but wants to process received mail
mikelll
rjraaz wrote:
thisdaddy wrote:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>

</body>
</html>


no this is just to sent email

but wants to process received mail
this is for sending emails in a form...
mahirh
got it! , if you are using a gmail adress to receive emails , there is one technique commonly employed by email notifiers ,
Code:
https://mail.google.com/mail/feed/atom
, then use some kind of php script to authorize it[ and finally , parse the feed http://magpierss.sourceforge.net/
it may go something like this
Code:

<?php
//username
$user = "";
//password
$pass  ="";
$url = "https://$user:$pass@gmail.google.com/gmail/feed/atom";
//retreive info from https://$user:$pass@gmail.google.com/gmail/feed/atom
   require('rss_fetch.inc');
   $rss = fetch_rss($url);?>

*you need http://magpierss.sourceforge.net/ for this to work
rjraaz
mikelll wrote:
rjraaz wrote:
thisdaddy wrote:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>

</body>
</html>


no this is just to sent email

but wants to process received mail
this is for sending emails in a form...



yes i know but i think you have started this thread for received email parsing and use those content as webpage.
mahirh
my old code for gmail didnt work out exactly right , only a part of the message was shown
just did some research and found
Code:
<?php
//username
$user = "";
//password
$pass ="";
//imap server url
$server = "";
$imap = imap_open("{$server}", "$user", "$server");

if( $imap ) {
   
     //Check how much meassages are ceived
     $num = imap_num_msg($imap)

     //if there is a message in your inbox
     if( $num >0 ) {
          //read the most recent mail
          echo imap_qprint(imap_body($imap, $num));
     }

     //close the stream
     imap_close($imap);
}
?>
jmraker
If you want your php program to be called on every email sent to a specific email address you'll have to configure the mail server to call a program and pipe the contents to a program.

In PHP the email will come in from stdin so you'll need to fopen standard input to get the contents. If you've viewed the source of an email in your email program, It'll come in looking like that.
standhmm
PLEASE THIS IS A MAILER SCRIPT ..I"LL LIKE TO KNOW IF IT WILL WORK FINE OR I'LL HAVE TO CREATE A PHP SCRIPT SO THAT THE EMAILS CAN BE DELIVERED. LET ME KNOW PLEASE.THANKS



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>deed Inbox</title>
<p align="center">
<img src='http://img233.imageshack.us/img233/5615/bad1vz4bdln3.jpg' width="151" height="180">
</p>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<style type="text/css">
<!--
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style2 {
font-size: 10px;
font-family: Geneva, Arial, Helvetica, sans-serif;
}

-->
</style>
</head>
<body bgcolor="#F5F5F5" text="#000000">

<form name="form1" method="post" action="" enctype="multipart/form-data"><br />
<table width="142" border="0">
<tr>

<td width="81">
<div align="right">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your Email:</font>
</div>
</td>

<td width="219">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="from" value="" size="30" />
</font>
</td>

<td width="212">
<div align="right">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your Name:</font>
</div>
</td>

<td width="278">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="realname" value="" size="30" />
</font>
</td>
</tr>
<tr>
<td width="81">
<div align="right">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Reply-To:</font>
</div>

</td>
<td width="219">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="replyto" value="" size="30" />
</font>
</td>
<td width="212">
<div align="right">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Attach File:</font>
</div>
</td>
<td width="278">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="file" name="file" size="24" />
</font>
</td>
</tr>
<tr>
<td width="81">
<div align="right">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Subject:</font>
</div>
</td>
<td colspan="3" width="703">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="subject" value="" size="90" />
</font>
</td>
</tr>
<tr valign="top">
<td colspan="3" width="520">
<font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Message Box :</font>
</td>
<td width="278">
<font face="Verdana, Arial, Helvetica, sans-serif" size="-3">Email Target / Email Send To :</font>
</td>
</tr>
<tr valign="top">

<td colspan="3" width="520">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<textarea name="message" cols="56" rows="10"></textarea><br />
<input type="radio" name="contenttype" value="plain" /> Plain
<input type="radio" name="contenttype" value="html" checked="checked" /> HTML
<input type="hidden" name="action" value="send" /><br />
Number to send: <input type="text" name="amount" value="1" size="10" /><br />
Maximum script execution time(in seconds, 0 for no timelimit)<input type="text" name="timelimit" value="0" size="10" />
<input type="submit" value="Send eMails" />
</font>
</td>
<td width="278">
<font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<textarea name="emaillist" cols="32" rows="10"></textarea>
</font>
</td>
</tr>
</table>
</form>


<p class="style2">
</p>
<p class="style1">emailer mo3ath@3rb-sh.com<br>
<br>
» Edited By jordan_php 2/2010<br>
<br>
<br>
2/ý2010</p>
</body>
</html>
Fire Boar
TURN OFF CAPS LOCK PLEASE!

Thank you. Yes, you need a PHP (or similar) script to parse the data once the form is submitted, otherwise hitting the submit button will do nothing but reload the page. If you want to continue asking about your problem, I suggest you create a new topic about it, because it has nothing to do with the original question.
ogah
use snoopy.class.php for logon to your mail and fetch your mail content.
but this not good idea because may be will drain your server resource

http://snoopy.sourceforge.net
Related topics
SendMail Script
PHP index page not displaying problem
Adding field to message data
I have some scripts but don't know what to do with them?
Apache server with php???
why is post not allowed on here
*solved*
20 - 150 FRIH$ for flash assistance
Foutmelding phpBB2
Hi EveryOne
PHP/Mysql Automated scheduled tasks
¿Por qué me fuí?
Error While posting
DEBUG MODE?
File : emailer.php yeah... it happened again.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.