7 Replies - 680 Views - Last Post: 27 September 2012 - 12:30 AM Rate Topic: -----

#1 gskill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 12

PHP Email problem.

Posted 26 September 2012 - 02:18 AM

Hello every1. I have a problem with sending e-mail using PHP.
I have writen the code, i think it is correct but it still isent working , im using windows 7 with xamp server apach and mysql server running so i dont get what the problem is. Here is the code
<?php

	$to='g_skill_the_man@yahoo.com';
    $subject='Commanda';
    $name=$_POST['name'];
    $email=$_POST['email'];
    $topic=$_POST['topic'];
    $message=$_POST['message'];
    
    $body =<<<EMAIL
    	
    Comanda de la $name
    Cu adressa de $mail
    $topic
    
    $message    
    EMAIL;
    
    $header= "From: $email";
    mail($to,$subject,$body,$headers);    

?><head>
	<link href="Styles/StylesContacte.CSS" rel="stylesheet" type="text/css">
    <title>Contacte</title>
    <script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
    </script>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
<hr />

	
    


<style type="text/css">
		form {
			width:480px;
			margin-left:auto;
			margin-right:auto;
			text-align:center;	
		}
		form ul {
			list-style-type:none;	
		}
		form ul li {
			margin:5px 5px;	
		}
		form label {
			display:block;
			border:#ccc;
			font-size:16px;	
		}
		form input , select{
			font-size:16px;
			width:100%;
			background-color:#FFFFFF;
		}
		
		#message textarea {
			border:solid 3px #ccc;
			background-color:#FFFFFF;
				
		}
	</style>
</head>
<body>
	<header>
    	<div id="banner">
        <img src="Pictures/Untitled-3.png" name="BannerPic" width="650" height="163" id="BannerPic">
        </div>
    
    </header>
<div id="menu">
  	<div id="menu_center">
   		   <ul>
           	<li><a href="Home.html">Home</a></li>
            <li><a href="Produse.html">Produse</a></li>	
           	<li><a href="Cumsefabrica.html">Cum se fabrica</a></li>
           	<li><a href="Mangalita.html">Mangalita</a></li>
            <li><a href="Contacte.html">Contacte </a></li>
       	  </ul>
    </div>
  </div>
	
  <div id="content">
	<div id="holder">
    	<div id="text1">
        	<textarea name="Description" cols="80" rows="23" readonly class="nosize-text" id="Desc" height="150" resize="none">
            </textarea>
            </div>
          <div id="mail">
          	<form action="?" method="post">
            	<ul>
                	<li>
                    	<label for="name">Numele:</label>
                        <input type="text" name="name" id="name" /> 
                	</li>
                    <li>
                    	<label for="email">Email:</label>
                        <input type="text" name="email" id="email" />
                    </li>
                    <li>
                    	<label for="topic">Comanda:</label>
                        <select id="topic" name="topic">
                        	<option value="Ponies">Salam</option>
                            <option value="Mexicans">Sunca</option>
                            <option value="Weiner">Carnati</option>
                        </select>
                    </li>
                    <li>
                    	<label for="message">Tell me something</label>
                        <textarea id="message" name="message" cols="42" rows="7">   </textarea>
                    </li>
                    <li>
                    	<input type="submit" value="Trimite">
                    </li>
                </ul>
            </form>		
          </div>  
    </div> 
    <footer>
     <table border="0" align="center" cellpadding="10" cellspacing="5" id="table1">
  <tr>
    <td><a href="Home.html">•Home</a></td>
    <td><a href="Produse.html"> •Produse</a></td>
    <td><a href="Cumsefabrica.html"> •Cum se fabrica</a></td>
    <td><a href="Mangalita.html"> •Mangalita</a></td>
    <td><a href="Contacte.html"> •Contacte</a></td>
  </tr>
</table>
 
 </footer>
  </div>  
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: PHP Email problem.

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1004
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: PHP Email problem.

Posted 26 September 2012 - 02:20 AM

Have you setup the smtp parameters in php.ini correctly? Meaning the server, also, you need to ensure that the server is able to accept anonymous emails to external servers.

Failing that, you can use a class such as phpMailer to do real SMTP Emailing with Authentication via Yahoo or whatever account you want to use.
Was This Post Helpful? 0
  • +
  • -

#3 gskill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 12

Re: PHP Email problem.

Posted 26 September 2012 - 02:24 AM

Can i please ask for a little more detalied solution ? like what do i need to edit in php.ini, and where.
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1004
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: PHP Email problem.

Posted 26 September 2012 - 02:35 AM

You can find full information here - http://php.net/manua...on.php#ini.smtp

The SMTP variable is what you need to set. But in all seriousness, you probably don't have a local mail server and probably don't have a remote server that would allow external delivery. In this case (and for the future) you're probably best sorting out phpMailer (or another SMTP Email Library).
Was This Post Helpful? 2
  • +
  • -

#5 gskill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 12

Re: PHP Email problem.

Posted 26 September 2012 - 03:15 AM

You are probably right, i use localhost with Xamp files, but as i noticed i couldent setup mail, on it.
I kinda ran out of idears how to setup my own server at home to send e-mail only for test.
And i cant aforth a server where to upload my files for testing.
Was This Post Helpful? 0
  • +
  • -

#6 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 446
  • View blog
  • Posts: 1,906
  • Joined: 30-April 10

Re: PHP Email problem.

Posted 26 September 2012 - 08:24 AM

View Postgskill, on 26 September 2012 - 03:15 AM, said:

You are probably right, i use localhost with Xamp files, but as i noticed i couldent setup mail, on it.
I kinda ran out of idears how to setup my own server at home to send e-mail only for test.
And i cant aforth a server where to upload my files for testing.

For testing things like mail and simple PHP scripts on the internet I have an account with 000webhost.com it is free and some good tools for a PHP developer that is testing on the web. I would not suggest it for production though.

Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#7 gskill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 26-September 12

Re: PHP Email problem.

Posted 26 September 2012 - 11:37 PM

No no, i want to just test my webpage so that i am sure it works fine and good. And then post it on a normal webhost for money :) thanks for the help.
Was This Post Helpful? 0
  • +
  • -

#8 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: PHP Email problem.

Posted 27 September 2012 - 12:30 AM

I've found it easiest, during development on sites that require PHP to send emails, to use PHPMailer or Swift Mailer, and have them send the emails through GMail. Then it is a simple matter, once the site is pushed to the production server, to switch over to whatever system that server supports. (Like Sendmail or another SMTP server.)

An example of how you can set PHPMailer up to use GMail can be found here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1