6 Replies - 1358 Views - Last Post: 27 January 2009 - 12:29 PM Rate Topic: -----

#1 vikas_naranje   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 23-January 09

Send mail using php

Post icon  Posted 23 January 2009 - 10:56 AM

I'm using this code for sending mail. But it's flashing warning

				  
<?php

$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
ini_set("sendmail_from",$from);
ini_set("SMTP","localhost");
if(mail($to,$subject,$message,$from)) {
  echo 'Mail Sent';
}
else  {
  echo 'Mail NOT Sent';
}


?>

My php.ini code like this

  [mail function]
; For Win32 only.
SMTP = smtp.my.isp.net
smtp_port = 25

; For Win32 only.
;sendmail_from = [email protected]




** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: Send mail using php

#2 kiwi2   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 178
  • Joined: 16-September 08

Re: Send mail using php

Posted 23 January 2009 - 11:45 AM

try
<?php
$Name = "kiwi2"; 

$email = "[email protected]"; 

$recipient = "[email protected]";
$mail_body = "test"; 

$subject = "test"; 

$header = "From: ". $Name . " <" . $email . ">\r\n"; 

mail($recipient, $subject, $mail_body, $header); 

?>



** Edit ** :code:
Was This Post Helpful? 0
  • +
  • -

#3 akozlik   User is offline

  • D.I.C Addict
  • member icon

Reputation: 92
  • View blog
  • Posts: 798
  • Joined: 25-February 08

Re: Send mail using php

Posted 23 January 2009 - 12:33 PM

Can everybody please paste your code between code tags. It makes it difficult to read without them. Thanks.

Also, what is the warning message it is flashing. That seems important.

This post has been edited by akozlik: 23 January 2009 - 12:33 PM

Was This Post Helpful? 0
  • +
  • -

#4 chili5   User is offline

  • D.I.C Lover

Reputation: 20
  • View blog
  • Posts: 1,146
  • Joined: 28-December 07

Re: Send mail using php

Posted 24 January 2009 - 05:21 AM

Do you perhaps not have a mail server setup? The code looks correct.

What is the error message?
Was This Post Helpful? 0
  • +
  • -

#5 Auzzie   User is offline

  • D.I.C Addict
  • member icon

Reputation: 43
  • View blog
  • Posts: 573
  • Joined: 20-January 09

Re: Send mail using php

Posted 24 January 2009 - 05:30 AM

if you running it off your own PC then you need to setup your own mail server on it before you can use ini_set("SMTP","localhost"); or mail in general, if you are on a web server, using that ini_set is not a good idea because if you have email with your hosting then you should use those settings
Was This Post Helpful? 0
  • +
  • -

#6 injh85   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-January 09

Re: Send mail using php

Posted 27 January 2009 - 11:21 AM

go download a free smtp email software, my guess is because you don't have a smtp email service running on your machine. at least thats what happened to me. after installing the smtp software i'm able to send email with my local machine.
Was This Post Helpful? 0
  • +
  • -

#7 Valek   User is offline

  • The Real Skynet
  • member icon

Reputation: 544
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Send mail using php

Posted 27 January 2009 - 12:29 PM

Please post the error message. That'll make it easier to debug.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1