Link to home
Start Free TrialLog in
Avatar of ashish2k
ashish2k

asked on

Sending email

Hi Friends
I am using Php on NT server with Apache. When I try to send email using the following command

mail("ashish@hotmail.com", "Test subject line ", "Test body of email", "From: ashish@expo.com\n")

It was giving the following error :-
           Failed to connect

then I downloaded one s/w called ftgate then after installing that the error changed to :-
           Warning: Failed to Receive in e:\php_workarea\jayesh\php_project\coemail.php on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in e:\php_workarea\jayesh\php_project\coemail.php on line 3

Can anyone tell me how to send mail and give the full coding currently I am using the following mail program :-

<?php
     if(mail("ashish@hotmail.com", "Test subject line ", "Test body of email", "From: ashish@expo.com\n"))
     {
          print('mail successfully sent');
     }
     else
     {
     //     print('oops! something didn't work right above, check the syntax of your code');
     }
?>

Bye
Waiting for your replies,
Ashish
ASKER CERTIFIED SOLUTION
Avatar of us111
us111
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ashish2k
ashish2k

ASKER

It's working us111 but I am facing the same problem in setting the session variables for myself I receive the following error :-
       Warning: Cannot send session cookie - headers already sent by (output started at e:\php_workarea\jayesh\php_project\loginnow.php:3) in e:\php_workarea\jayesh\php_project\loginnow.php on line 29

Warning: Cannot send session cache limiter - headers already sent (output started at e:\php_workarea\jayesh\php_project\loginnow.php:3) in e:\php_workarea\jayesh\php_project\loginnow.php on line 29
 For this do I have to do some changes in php.ini only or something please let me know I will be very thankful to you but this session_start() is working in a new file.
Bye
Thanks
It means that you send something to the browser before sending header:

print "hello";
session_start();

won't work and you will get a warning
Hi us111
You are right if I right something before session_start(); then it prints hello but after that gives the same two warnings I had told you before. Please tell me how can I remove these warnings and how can I create session variables in PHP.

Warning: Cannot send session cookie - headers already sent by (output started at e:\php_workarea\jayesh\php_project\loginnow.php:3)
in e:\php_workarea\jayesh\php_project\loginnow.php on line 29

Warning: Cannot send session cache limiter - headers already sent (output started at e:\php_workarea\jayesh\php_project\loginnow.php:3)
in e:\php_workarea\jayesh\php_project\loginnow.php on line 29

Wherever in my code I right session_start(); the error comes in that line, in this case I have written in line 29. Can you please tell me a way whereby I can remove this error. Please also tell whether I have to make some changes in php.ini file or not.
Thanking you in advance
Bye
Waiting for your reply.
Ashish