473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Trouble sending email using php form

Hi I am going crazy trying to send an email using XAMPP, my php form on my localhost server.

This is the email section of the code

Expand|Select|Wrap|Line Numbers
  1. if($insert_result)
  2.         {    
  3.  
  4.             ini_set('SMTP', 'ssl://smtp.gmail.com');
  5.             ini_set('smtp_port', 465); 
  6.             ini_set('sendmail_from', 'myemail@gmail.com');
  7.             ini_set('sendmail_path', 'localhost\C:\Program Files\xampp\sendmail\sendmail.exe');$to = $_REQUEST['email'];
  8.             $message = "Please fill out a survey form. Follow this link---> <a href='{$email_link}'>HERE</a> to load the form.<br>";
  9.             $nameTo = "Dear User"; 
  10.             $subject = "Form completion required!";
  11.             $headers = "MIME-Version: 1.0" . '\r\n';
  12.             $headers .= "Content-type: text/html; charset=iso-8859-1" . '\r\n';
  13.             $headers .= "From: myemail@gmail.com" . '\r\n';
  14.  
  15.             $sent = mail($to, $subject, $message, $headers) ; 
  16.             if($sent) 
  17.             {print "Your mail was sent successfully"; }
  18.             else 
  19.             {print "We encountered an error sending your mail";
  20.             echo $message;
  21.             phpinfo();
  22.             }
  23.  
Right now, I am trying to use gmail's SMTP server. And it gives the following error:

Warning: mail() [function.mail]: Failed to connect to mailserver at "ssl://smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\survey.php on line 328

I modified the sendmail.ini and entered my username and password in the auth_username and auth_password fields and restarted XAMPP. No result.

Earlier I tried sending using my company's ISP server. But it says Client is not authenticated.

I printed phpinfo() to check whats wrong. Its using the same php.ini file I am modifying and the local values of SMTP and smtp_port are changing but not the master values.

Mercury is running in my XAMPP Control Panel. Do I need to setup mercury? I just can't figure this out. I really hope someone can help me sort this out ASAP. Much appreciated.
Jun 29 '12 #1
1 3279
Luuk
1,047 Expert 1GB
change line 4 to:
Expand|Select|Wrap|Line Numbers
  1. ini_set('SMTP', 'smtp.gmail.com'); 
  2.  
This is because PHP does not know how to do 'ssl://', and thats why it says "Failed to connect to mailserver at "ssl://smtp.gmail.com" port ......"
Jul 1 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robert Pettersson | last post by:
Hi, I have built an webapp in C# that uses SMTPMail to send mail to users. When I installed it on the prodserver everything worked fine for me, but the users can not send mail. They get Access...
3
by: Srinivas | last post by:
Hi, I am using ASP.NET SmtpMail to send email using the following code public void SendEmail(string From, string To, string Subject, StringBuilder Message, string Attachment, string...
6
by: lalit26011983 | last post by:
Can any1 help me... How to send emails using asp.net.. I m using windows 2000 server and visual studio 2003(.net framework 1.1) I m not getting any error while i m sending email using...
2
by: Nathan Sokalski | last post by:
I have an ASP.NET 2.0 application that is supposed to send an email after a certain form is submitted. When it tries to send the email, I receive the following error: Transaction failed. The...
0
by: Sister Ray | last post by:
I'm trying to create a simple form that sends an email using my company's exchange server. I'm using the System.Net.Mail Namespace of the .net framework 2.0. I've googled everywhere and i think my...
3
simpleton
by: simpleton | last post by:
Hey all, I'm new to this board. I'm trying to send email via a "contact us" form .asp page. I've setup SMTP Virtual Server on my local XP IIS 5.1 machine. I told it to relay with 127.0.0.1 ...
2
by: haytham2008 | last post by:
hi every body i have this problem while i trying to send email using php i found a function <?php mail(); ?> but does not work with me since i use smtp server with user name and password
3
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only...
0
by: trivedimca2005 | last post by:
I am using below code for sending Email using .net. Its not working on client machine. My server IP is:- 192.168.10.10 and also uses proxy and user-name and password for proxy settings are...
6
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.