473,396 Members | 2,061 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,396 software developers and data experts.

How to Send Mail with account activation link after filling up registration form

I am trying to send an automatic mail containing the account activation link to the person who is filling up the registration form after he/she clicks on Create account button. But every time it giving an error .... Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. w42sm3532376wfh.15 in C:\wamp\www\KeyWest\NewRegister.php on line 66... can I get some help. The code I have written is as follows:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="keywest";
  5. $host="localhost";
  6. $msg="";
  7. mysql_connect($host,$username,$password);
  8. @mysql_select_db($database);
  9.  
  10. if(!empty($_POST['register']))
  11. {
  12.   $mail=$_POST['eml'];
  13.   $firstname=$_POST['fnm'];
  14.   $lastname=$_POST['lnm'];
  15.   $address=$_POST['adr'];
  16.   $city=$_POST['city'];
  17.   $pin=$_POST['pin'];
  18.   $state=$_POST['stt'];
  19.   $country=$_POST['cnt'];
  20.   $contact=$_POST['cntct'];
  21.   $sex=$_POST['sex'];
  22.   $pass1=$_POST['pwd1'];
  23.   $pass2=$_POST['pwd2'];
  24.   $status="inactive";
  25.  
  26.  
  27.   $sql="SELECT * FROM user WHERE email='$mail'";
  28.   $result=mysql_query($sql);
  29.   $row = mysql_fetch_assoc($result);
  30.  
  31.   // Mysql_num_row is counting table row
  32.   $num = mysql_num_rows($result);
  33.  
  34.   // If result matched $mail, table row must be 1 row
  35.   if($num>0)
  36.   {
  37.     $msg="Please use another valid Email ID....";
  38.   }
  39.   else if($pass1!=$pass2)
  40.   {
  41.     $msg="Please repeat password properly .....  ";
  42.   }
  43.   else
  44.   {
  45.  
  46.     //ini_set("SMTP","smtp.mydomain.com");
  47.     //ini_set("smtp_port","25");
  48.     //ini_set("sendmail_from","user@mydomain.com"); 
  49.     //mail($To,$Subject,$Message,$From);
  50.  
  51.     $sql="insert into user values('$mail', '$pass1', '$firstname', '$lastname', '$status', '$address', '$city', '$pin', '$state', '$country', '$contact', '$sex')";
  52.     mysql_query($sql);
  53.     $to=$mail;
  54.     $subject="KeyWest Account Activation..";
  55.     $message="Welcome to KeyWest. You have created an account with us. Please go through the following link to activate your account.";
  56.     $message=$message."\r\r http://localhost/KeyWest/Activation.php?var=".$mail;
  57.     $message=$message."\r\r If this is an unwanted message for you, please use the following link.";
  58.     $message=$message."\r\r http://localhost/KeyWest/DeActivate.php?var=".$mail;
  59.     $header='From: ranadip.chakraborty@gmail.com';
  60.     ini_set("SMTP","smtp.gmail.com");
  61.     ini_set("smtp_port","587");
  62.     ini_set("smtp_ssl","auto");
  63.     ini_set("sendmail_from","ranadip.chakraborty@gmail.com");
  64.     ini_set("auth_username","ranadip.chakraborty");
  65.     ini_set("auth_password","Electronics");
  66.     mail($to, $subject, $message, $header);
  67.     $msg="Record Entered Successfully. Please check your email and activate your account....";
  68.   }
  69.   mysql_free_result($result);
  70. }
  71. ?>
  72. <html>
  73. <body background='Images/Back15.jpg' text='black'>
  74. <br><br>
  75. <center>
  76. <form action="NewRegister.php" method=POST>
  77. <center>
  78. <table cellpadding="0" cellspacing="0" border="0">
  79. <tr>
  80.   <td width="14"><img src="TableImage/TL.png" width=14 height=23 border="0" /></td>
  81.  
  82.   <td background="Images/Back1.jpg" colspan="2" align="center">
  83.     <font face='arial' size='4' color='maroon'><strong>
  84.     Registration Form:
  85.     </font>
  86.   </td>
  87.  
  88. <td width="14"><img src="TableImage/TR.png" width=14 height=23 border="0" /></td>
  89.  
  90. </tr>
  91.  
  92. <tr>
  93.  
  94. <td background="Images/Back1.jpg">&nbsp</td>
  95. <td background="Images/Back1.jpg">&nbsp</td>
  96. <td background="Images/Back1.jpg">&nbsp</td>
  97. <td background="Images/Back1.jpg">&nbsp</td>
  98.  
  99. </tr>
  100.  
  101. <tr>
  102.  
  103. <td background="Images/Back1.jpg"></td>
  104.  
  105. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Email-ID:</font></td>
  106. <td background="Images/Back1.jpg"><input type='text' name='eml'/></td>
  107.  
  108. <td background="Images/Back1.jpg"></td>
  109.  
  110. </tr>
  111.  
  112. <tr>
  113.  
  114. <td background="Images/Back1.jpg">&nbsp</td>
  115. <td background="Images/Back1.jpg">&nbsp</td>
  116. <td background="Images/Back1.jpg">&nbsp</td>
  117. <td background="Images/Back1.jpg">&nbsp</td>
  118.  
  119. </tr>
  120.  
  121. <tr>
  122.  
  123. <td background="Images/Back1.jpg"></td>
  124.  
  125. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>First Name:</font></td>
  126. <td background="Images/Back1.jpg"><input type='text' name='fnm'/></td>
  127.  
  128. <td background="Images/Back1.jpg"></td>
  129.  
  130. </tr>
  131.  
  132. <tr>
  133.  
  134. <td background="Images/Back1.jpg">&nbsp</td>
  135. <td background="Images/Back1.jpg">&nbsp</td>
  136. <td background="Images/Back1.jpg">&nbsp</td>
  137. <td background="Images/Back1.jpg">&nbsp</td>
  138.  
  139. </tr>
  140.  
  141. <tr>
  142.  
  143. <td background="Images/Back1.jpg"></td>
  144.  
  145. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Last Name:</font></td>
  146. <td background="Images/Back1.jpg"><input type='text' name='lnm'/></td>
  147.  
  148. <td background="Images/Back1.jpg"></td>
  149.  
  150. </tr>
  151.  
  152. <tr>
  153.  
  154. <td background="Images/Back1.jpg">&nbsp</td>
  155. <td background="Images/Back1.jpg">&nbsp</td>
  156. <td background="Images/Back1.jpg">&nbsp</td>
  157. <td background="Images/Back1.jpg">&nbsp</td>
  158.  
  159. </tr>
  160.  
  161. <tr>
  162.  
  163. <td background="Images/Back1.jpg"></td>
  164.  
  165. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Address:</font></td>
  166. <td background="Images/Back1.jpg"><input type='text' name='adr'/></td>
  167.  
  168. <td background="Images/Back1.jpg"></td>
  169.  
  170. </tr>
  171.  
  172. <tr>
  173.  
  174. <td background="Images/Back1.jpg">&nbsp</td>
  175. <td background="Images/Back1.jpg">&nbsp</td>
  176. <td background="Images/Back1.jpg">&nbsp</td>
  177. <td background="Images/Back1.jpg">&nbsp</td>
  178.  
  179. </tr>
  180.  
  181. <tr>
  182.  
  183. <td background="Images/Back1.jpg"></td>
  184.  
  185. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>City:</font></td>
  186. <td background="Images/Back1.jpg"><input type='text' name='city'/></td>
  187.  
  188. <td background="Images/Back1.jpg"></td>
  189.  
  190. </tr>
  191.  
  192. <tr>
  193.  
  194. <td background="Images/Back1.jpg">&nbsp</td>
  195. <td background="Images/Back1.jpg">&nbsp</td>
  196. <td background="Images/Back1.jpg">&nbsp</td>
  197. <td background="Images/Back1.jpg">&nbsp</td>
  198.  
  199. </tr>
  200.  
  201. <tr>
  202.  
  203. <td background="Images/Back1.jpg"></td>
  204.  
  205. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Pin:</font></td>
  206. <td background="Images/Back1.jpg"><input type='text' name='pin'/></td>
  207.  
  208. <td background="Images/Back1.jpg"></td>
  209.  
  210. </tr>
  211.  
  212. <tr>
  213.  
  214. <td background="Images/Back1.jpg">&nbsp</td>
  215. <td background="Images/Back1.jpg">&nbsp</td>
  216. <td background="Images/Back1.jpg">&nbsp</td>
  217. <td background="Images/Back1.jpg">&nbsp</td>
  218.  
  219. </tr>
  220.  
  221. <tr>
  222.  
  223. <td background="Images/Back1.jpg"></td>
  224.  
  225. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>State:</font></td>
  226. <td background="Images/Back1.jpg"><input type='text' name='stt'/></td>
  227.  
  228. <td background="Images/Back1.jpg"></td>
  229.  
  230. </tr>
  231.  
  232. <tr>
  233.  
  234. <td background="Images/Back1.jpg">&nbsp</td>
  235. <td background="Images/Back1.jpg">&nbsp</td>
  236. <td background="Images/Back1.jpg">&nbsp</td>
  237. <td background="Images/Back1.jpg">&nbsp</td>
  238.  
  239. </tr>
  240.  
  241. <tr>
  242.  
  243. <td background="Images/Back1.jpg"></td>
  244.  
  245. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Country:</font></td>
  246. <td background="Images/Back1.jpg"><input type='text' name='cnt'/></td>
  247.  
  248. <td background="Images/Back1.jpg"></td>
  249.  
  250. </tr>
  251.  
  252. <tr>
  253.  
  254. <td background="Images/Back1.jpg">&nbsp</td>
  255. <td background="Images/Back1.jpg">&nbsp</td>
  256. <td background="Images/Back1.jpg">&nbsp</td>
  257. <td background="Images/Back1.jpg">&nbsp</td>
  258.  
  259. </tr>
  260.  
  261. <tr>
  262.  
  263. <td background="Images/Back1.jpg"></td>
  264.  
  265. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Contact:</font></td>
  266. <td background="Images/Back1.jpg"><input type='text' name='cntct'/></td>
  267.  
  268. <td background="Images/Back1.jpg"></td>
  269.  
  270. </tr>
  271.  
  272. <tr>
  273.  
  274. <td background="Images/Back1.jpg">&nbsp</td>
  275. <td background="Images/Back1.jpg">&nbsp</td>
  276. <td background="Images/Back1.jpg">&nbsp</td>
  277. <td background="Images/Back1.jpg">&nbsp</td>
  278.  
  279. </tr>
  280.  
  281. <tr>
  282.  
  283. <td background="Images/Back1.jpg"></td>
  284.  
  285. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Sex:</font></td>
  286. <td background="Images/Back1.jpg">    <input type='radio' name='sex' value="M" />Male
  287.                                     <input type='radio' name='sex' value="F" />Female</td>
  288.  
  289. <td background="Images/Back1.jpg"></td>
  290.  
  291. </tr>
  292.  
  293. <tr>
  294.  
  295. <td background="Images/Back1.jpg">&nbsp</td>
  296. <td background="Images/Back1.jpg">&nbsp</td>
  297. <td background="Images/Back1.jpg">&nbsp</td>
  298. <td background="Images/Back1.jpg">&nbsp</td>
  299.  
  300. </tr>
  301.  
  302. <tr>
  303.  
  304. <td background="Images/Back1.jpg"></td>
  305.  
  306. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Login Password:</font></td>
  307. <td background="Images/Back1.jpg"><input type='password' name='pwd1'></td>
  308.  
  309. <td background="Images/Back1.jpg"></td>
  310.  
  311. </tr>
  312.  
  313. <tr>
  314.  
  315. <td background="Images/Back1.jpg">&nbsp</td>
  316. <td background="Images/Back1.jpg">&nbsp</td>
  317. <td background="Images/Back1.jpg">&nbsp</td>
  318. <td background="Images/Back1.jpg">&nbsp</td>
  319.  
  320. </tr>
  321.  
  322. <tr>
  323.  
  324. <td background="Images/Back1.jpg"></td>
  325.  
  326. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='2'>Repeat Password:</font></td>
  327. <td background="Images/Back1.jpg"><input type='password' name='pwd2'></td>
  328.  
  329. <td background="Images/Back1.jpg"></td>
  330.  
  331. </tr>
  332.  
  333. <tr>
  334.  
  335. <td background="Images/Back1.jpg">&nbsp</td>
  336. <td background="Images/Back1.jpg">&nbsp</td>
  337. <td background="Images/Back1.jpg">&nbsp</td>
  338. <td background="Images/Back1.jpg">&nbsp</td>
  339.  
  340. </tr>
  341.  
  342. <tr>
  343.  
  344. <td background="Images/Back1.jpg">&nbsp</td>
  345.  
  346. <td background="Images/Back1.jpg" align="center" colspan="2"><input type='submit' name='register' value='  Create Account  '></td>
  347.  
  348. <td background="Images/Back1.jpg">&nbsp</td>
  349.  
  350. </tr>
  351.  
  352. <tr>
  353.  
  354. <td><img src="TableImage/BL.png" width=14 height=23 border="0" /></td>
  355. <td background="Images/Back1.jpg">&nbsp</td>
  356. <td background="Images/Back1.jpg">&nbsp</td>
  357. <td><img src="TableImage/BR.png" width=14 height=23 border="0" /></td>
  358.  
  359. </tr>
  360. </table>
  361. </center>
  362. <p align=Center><?php echo $msg ?></p>
  363. </form>
  364.  
Dec 10 '10 #1
3 4930
johny10151981
1,059 1GB
look at mail function provided by php

mail: follow the link and try to understand the examples. You can manage very fine with this
Dec 10 '10 #2
I am maintaining the mail function signature perfectly. But, the error is still there. I guess I have messed up something with ini_set() but not getting it. I need the total php settings or example to send the mail from my php page through my gmail account.
Can you please help me?
Even if I copied the code from the referred link. Still it is not working an it is giving the following error:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\Test_2\TestMail.php on line 41
Dec 10 '10 #3
JKing
1,206 Expert 1GB
You would have to have a mail server setup locally for this to work. Try running this on a web server.
Dec 10 '10 #4

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

Similar topics

2
by: R. Rajesh Jeba Anbiah | last post by:
I'm supposed to do the account activation via email. I mean *not* sending the activation link like http://foo.com/foo.php?actcode=foo. But, I would like it to be like...
1
by: chalk | last post by:
xp_sendmail has died on our SQL Server, I get error "xp_sendmail: failed with mail error 0x80004005" if I try using it. I believe that the reason that this has happened is because the SQL Server...
3
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it...
2
by: Susanne | last post by:
HI I built a website (for someone else) that sends several data fields to an aol e-mail account. I have noticed on several occasions that the data fields are passed blank to the e-mail. When I...
12
by: Geethu03 | last post by:
Hi to all I am a new member to this group. I have a problem in Email Sending using java. That is the mail is sending from my server to any desired mail account. By using the html i created the form...
1
by: mobs6 | last post by:
This error messages always shown up, after i filled the registration form Can some body tell me about this problems, ok this is error the message looks like: " sendmail: Can't send mail: Sender...
1
by: archana | last post by:
Hi all, I want to develop one web application. What i want is to allow user to create account but at that time before giving rights to that user admin should accept this person's account. So...
1
by: gopim | last post by:
in my database having registration table.if any one regster with my site then that person login details will be stored in this registration table.then for that registerd user i want to send mail...
7
by: John Drako | last post by:
Currently, I run postfix on my own server to send message from my site (password requests, account activation notices and other messages). I have phpMailer on the server and all the messages...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.