My USJ-R Community Forum My.USJ-R WebMail USJ-R Home Page

User Info
No avatar Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
July 31, 2010, 05:53:38 am
* Home Help Login Register

+  My USJ-R - The University Portal Forum
|-+  Web Support
| |-+  Technical Support (Moderator: moodsey211)
| | |-+  Problem in PHP!
0 Members and 1 Guest are viewing this topic.
Pages: [1] Go Down Print

 Problem in PHP!
realew1


Adelante Points: 0
Offline Offline

Gender: Female
Posts: 2

WWW

« Posted on: November 23, 2008, 08:48:49 pm »

Does anyone guide me that how can i make PHP email form? Actually, I have made email form but i have found some problem on that...!
Logged

Imagination is more important than knowledge.

 Re: Problem in PHP!
moodsey211
Moderator
Super Newbie
*****

Adelante Points: 400
Offline Offline

Gender: Male
Posts: 420


WWW

« Reply #1 Posted on: November 24, 2008, 03:34:26 pm »

Does anyone guide me that how can i make PHP email form? Actually, I have made email form but i have found some problem on that...!

Sending an email in PHP requires you to have a Mail Server. If you have none well that's really a problem.  Can you post some code snippets so it would be much be easier for us to identify the problem?
Logged

(http://www.neobux.com/?r=moodsey211)

 Re: Problem in PHP!
8thstreet
Guest


Email

« Reply #2 Posted on: November 26, 2008, 01:50:21 pm »

First and foremost, you need to post what problem you are having problem with in your form. You can't let people here post answers while guessing what your problem is. Though i will try give you some idea which i have tried too.

If you are using the php mail() system, then i guess the only way to get it to work is to edit the php.ini.

Though there are many frameworks that is useful in a mail system, and one of those is the Zend Mail.

Another is the Swift Mailer, though its quite complicated framework but it do provides you almost all the functionalities (eg. embedding images, html, etc..)
Logged

 Re: Problem in PHP!
moodsey211
Moderator
Super Newbie
*****

Adelante Points: 400
Offline Offline

Gender: Male
Posts: 420


WWW

« Reply #3 Posted on: November 27, 2008, 07:49:54 am »

First and foremost, you need to post what problem you are having problem with in your form. You can't let people here post answers while guessing what your problem is.

Yup. How can anyone answer you if you've just let people glimpse at your problem.  You really have to explain the situation and what is your expected outcome about that situation.

If your going to use the mail function of php. be sure you have a working SMTP Server.
Logged

(http://www.neobux.com/?r=moodsey211)

 Re: Problem in PHP!
realew1


Adelante Points: 0
Offline Offline

Gender: Female
Posts: 2

WWW

« Reply #4 Posted on: November 30, 2008, 02:37:30 pm »

Here are the scripts where i am facing a problem, check below:

   if($_POST['hdnOperationCode'] == 1) // if this form is post back
   {
         $my_query = "Select Password From UserProfile where Email= '" . $_POST['txtEmail'] . "'";
         $my_query = $my_query . " and ID = " . $_SESSION["ID"];
         $query_result = ExecuteQuery($my_query);
         if(mysql_num_rows($query_result) != 1)
         {
            echo ("<html><body>Invalid Email Address <a href='#' onclick='history.back()'> Click Here to Try Again</a></body></html>");
            exit();
         }
         else
         {
            $row    = mysql_fetch_object($query_result);
            $Password=$row->Password;

         }
         mail('abc@gmail.com','testing','testing body');
         exit();

   }

In this script i am facing a problem in SMTP sending mail and i have tried many times but problem is still on the same position.
Could you please help me out in this meter?
Logged

Imagination is more important than knowledge.

 Re: Problem in PHP!
moodsey211
Moderator
Super Newbie
*****

Adelante Points: 400
Offline Offline

Gender: Male
Posts: 420


WWW

« Reply #5 Posted on: December 01, 2008, 08:39:20 am »

you need to configure your php.ini to provide the from header. or you can have it this way

Code:
mail('abc@gmail.com','testing','testing body',"from:moodsey211@gmail.com");

The second thing is that you need to have a valid SMTP server.


and try to use a code tag if you are going to post codes. Like the one above.

Cheers...
Logged

(http://www.neobux.com/?r=moodsey211)

 Re: Problem in PHP!
8thstreet
Guest


Email

« Reply #6 Posted on: December 02, 2008, 10:33:11 am »

PHP makes it easy to send mail from Web applications. But it still needs a bit of configuration. As you probably know, PHP configuration happens php.ini.

The relevant section for email configuration is [mail function], and to make PHP use an external mail server you must set SMTP to your ISP's mail server's address. This will be the same address that you use in your email program for the outgoing mail server, "smtp.isp.net", for example. The other setting sendmial_from, which specifies the default email address PHP emails are sent from.
Configure PHP to Use a Remote SMTP Server for Sending Mail

Note that setting up the internal mail function to use SMTP is only available on Windows. On other platforms, PHP should use the locally available sendmail or sendmail drop-in just fine. Alternatively, you can use the PEAR Mail Package.

A typical configuration might look like:

[mail function]
SMTP = smtp.isp.net
sendmail_from = me@isp.net

Code:
http://email.about.com/cs/phpemailtips/qt/et021802.htm

Further References:
Code:
http://www.google.com.ph/search?hl=en&q=configuring+the+SMTP+server+in+php.ini&btnG=Google+Search&meta=
Logged

 Re: Problem in PHP!
moodsey211
Moderator
Super Newbie
*****

Adelante Points: 400
Offline Offline

Gender: Male
Posts: 420


WWW

« Reply #7 Posted on: December 02, 2008, 04:33:26 pm »

PHP makes it easy to send mail from Web applications. But it still needs a bit of configuration. As you probably know, PHP configuration happens php.ini.

The relevant section for email configuration is [mail function], and to make PHP use an external mail server you must set SMTP to your ISP's mail server's address. This will be the same address that you use in your email program for the outgoing mail server, "smtp.isp.net", for example. The other setting sendmial_from, which specifies the default email address PHP emails are sent from.
Configure PHP to Use a Remote SMTP Server for Sending Mail

Note that setting up the internal mail function to use SMTP is only available on Windows. On other platforms, PHP should use the locally available sendmail or sendmail drop-in just fine. Alternatively, you can use the PEAR Mail Package.

A typical configuration might look like:

[mail function]
SMTP = smtp.isp.net
sendmail_from = me@isp.net

Code:
http://email.about.com/cs/phpemailtips/qt/et021802.htm

Further References:
Code:
http://www.google.com.ph/search?hl=en&q=configuring+the+SMTP+server+in+php.ini&btnG=Google+Search&meta=

In short you really have to read the technical documentation of php.  You can set it up at the php.ini or you could use the ini_set function.  Both methods are correct, but you need a precise understanding on how SMTP works.  Take not that sending mail in windows and unix are different.

You can use gmail as a Mail Server but you need to have a gmail account first. and you need to send message using that account.

If you need more assistance please do refer to their documentation:
Code:
http://www.php.net/manual/en/function.mail.php
Logged

(http://www.neobux.com/?r=moodsey211)

 Re: Problem in PHP!
flashMaster


Adelante Points: 0
Offline Offline

Gender: Male
Posts: 36


My.USJ-R Forum User



« Reply #8 Posted on: December 09, 2008, 02:33:16 pm »

try what moodsey posted by doing a simple script first.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
   <head>
      <title></title>
   </head>
   <body>
      <?php
         //ini_set("sendmail_from", "me@yahoo.com");
         $sSender = "me@yahoo.com";
         $sReceiver = "them@yahoo.com";
         $sTitle = "My Test Subject";
         $sMsg = "My test message.";
         mail($sReceiver, $sMsg, $sTitle, $sSender);
      ?>
   </body>
</html>
If it doesn't work, maybe you really do need a mail agent.
Configure an MTA to your IIS if you're using Windows.
If XAMPP, try visiting http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

Maybe you can use google as your SMTP here hehehe http://lifehacker.com/software/email-apps/how-to-use-gmail-as-your-smtp-server-111166.php
I haven't tried google's, but I think it should work much like setting your Outlook.
Logged



There are 10 types of people in this world - those who understand binary and those who do not (2 Sides of Everything...)

 Re: Problem in PHP!
flashMaster


Adelante Points: 0
Offline Offline

Gender: Male
Posts: 36


My.USJ-R Forum User



« Reply #9 Posted on: December 09, 2008, 02:46:31 pm »

try what moodsey posted by doing a simple script first.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
   <head>
      <title></title>
   </head>
   <body>
      <?php
         //ini_set("sendmail_from", "me@yahoo.com");
         $sSender = "me@yahoo.com";
         $sReceiver = "them@yahoo.com";
         $sTitle = "My Test Subject";
         $sMsg = "My test message.";
         mail($sReceiver, $sMsg, $sTitle, $sSender);
      ?>
   </body>
</html>
If it doesn't work, maybe you really do need a mail agent.
Configure an MTA to your IIS if you're using Windows.
If XAMPP, try visiting http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

Maybe you can use google as your SMTP here hehehe http://lifehacker.com/software/email-apps/how-to-use-gmail-as-your-smtp-server-111166.php
I haven't tried google's, but I think it should work much like setting your Outlook.

woops wrong link hehe!  On XAMPP, you might wanna enable SMTP on Moodle or Mercury.
Logged



There are 10 types of people in this world - those who understand binary and those who do not (2 Sides of Everything...)

 Re: Problem in PHP!
moodsey211
Moderator
Super Newbie
*****

Adelante Points: 400
Offline Offline

Gender: Male
Posts: 420


WWW

« Reply #10 Posted on: December 11, 2008, 08:39:46 am »

If you really don't want to go to the hustle of configuring your own SMTP server. You can always choose to use third party programs that does the job for you. For example you could use telnet[1] to connect to gmail or any SMTP server to send and/or download your emails.  By studying how this program work you can figure out how to use it in your php.  It has some issues but it does what you really want to achieve.

[1] telnet is a Microsoft program use before by our teachers to remotely connect to our server to download their email.

More info about telnet in this site:
Code:
http://en.wikipedia.org/wiki/Telnet

You could also use ActiveEmail to send email. It's not free but you could always try it.
Code:
http://www.activexperts.com/ActivEmail/
Logged

(http://www.neobux.com/?r=moodsey211)

Pages: [1] Go Up Print 
« previous next »
Jump to:  



Login with username, password and session length

Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC
Page created in 0.225 seconds with 23 queries.

Copyright