paul.hirak Posted January 16, 2009 Share Posted January 16, 2009 Hey..I am new to PHP. I want to send E-mail using PHP script from Gmail SMTP. I Developed the Below Code But it Can't send any e-mail to the Recipient Address.Would you please Help me out What is the Main problem of this Script. I am Using XAMPP-1.6.7. I want to send E-mail by PEAR package. My Email ID is: [email protected] ......Please Help me. Thanks In Advanced. <?php require_once"Mail.php"; if($_POST['Submit']) { $Name = $_POST['Name']; $Email = $_POST['Email']; $Phone = $_POST['Phone']; $Company = $_POST['Company']; $URL = $_POST['URL']; $Find_Us = $_POST['Find_Us']; $Interest = $_POST['Interest']; $Borrower = $_POST['Borrower']; $Comments = $_POST['Comments']; $from="[email protected]"; //Sender Address $to = '[email protected]'; $subject='Testing for Sending Mail using Gmail SMTP......!!!!'; //$to = '[email protected]'; $message = $Name.' '.$Email.' '.$Phone.' '.$Company.' '.$URL. ' '.$Find_Us.' '.$Interest.' '.$Borrower.' '.$Comments; // Identify the mail server, username, password, and port $server="smtp.gmail.com"; $port="465"; //$protocol="smtps"; $username="[email protected]"; $password="Password"; // Set up the mail headers $headers=array( "From"=>$from, "To"=>$to, "Subject"=>$subject ); // Configure the mailer mechanism $smtp=Mail::Factory("smtp", array( "host"=>$server, "username"=>$username, "password"=>$password, //"protocol"=>$protocol, "auth"=>"true", "port"=>"465", //"starttls.enable"=>true ) ); // Send the message $mail=$smtp->send($to,$headers,$message); if( PEAR::isError($mail)) { echo($mail->getMessage()); } else { echo ('mail has been sent'); } } ?> <form name="quick_quote_form" id="quick_quote_form" action="" method="post"> <table width="100%" border="0" cellspacing="1" cellpadding="5"> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="5"> <tr> <td> Name: </td> <td> <input name="Name" type="text" id="Name"> </td> </tr> <tr> <td> E-mail: </td> <td> <input name="Email" type="text" id="Email"> </td> </tr> <tr> <td> Phone: </td> <td> <input name="Phone" type="text" id="Phone"> </td> </tr> <tr> <td> Company Name: </td> <td> <input name="Company" type="text" id="Company"> </td> </tr> <tr> <td> Web Address: </td> <td> <input name="URL" type="text" id="URL"> </td> </tr> <tr> <td> How did you find us? </td> <td> <select name="Find_Us" id="Find_Us"> <option value="Select" selected>Select</option> <option value="Internet">Internet</option> <option value="Sales Rep">Sales Rep</option> <option value="Tradeshow">Tradeshow</option> <option value="Other">Other</option> </select> </td> </tr> <tr> <td> Desired Service? </td> <td> <select name="Interest" id="Interest"> <option value="Select" selected>Select</option> <option value="Inbound Call Center">Inbound Call Center</option> <option value="Outbound Call Center">Outbound Call Center</option> <option value="Back Office Outsourcing">Back Office Outsourcing</option> </select> </td> </tr> <tr> <td> Monthly Budget? </td> <td> <select name="Borrower" id="Borrower"> <option value="Select" selected>Select</option> <option value="$500 - $1,000">$500 - $1,000</option> <option value="$1,000 - $2,500">$1,000 - $2,500</option> <option value="$2,500 - $5,000">$2,500 - $5,000</option> <option value="$5,000 - $10,000">$5,000 - $10,000</option> <option value="$10,000 - $15,000">$10,000 - $15,000</option> <option value="$15,000 - $20,000">$15,000 - $20,000</option> <option value="$20,000 - $30,000">$20,000 - $30,000</option> <option value="$30,000 - $40,000">$30,000 - $40,000</option> <option value="$40,000 - $50,000">$40,000 - $50,000</option> <option value="$50,000 - $75,000">$50,000 - $75,000</option> <option value="$75,000 - $100,000">$75,000 - $100,000</option> <option value="$100,000 Plus">$100,000 Plus</option> </select> </td> </tr> </table> </td> </tr> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="5"> <tr> <td>Comments/Questions:<br> <textarea name="Comments" id="Comments"></textarea> </td> </tr> </table> </td> </tr> <tr> <td> <input name="Submit" type="submit" value="Submit"> </td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/141056-how-can-i-send-e-mail-using-pear-package-in-php-and-gmail-smtp/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.