Current location: Hot Scripts Forums » Programming Languages » PHP » beginner question regarding smtp server sending mail


beginner question regarding smtp server sending mail

Reply
  #1 (permalink)  
Old 12-05-05, 03:31 AM
martin_ua martin_ua is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Question beginner question regarding smtp server sending mail

Hi, I just grab the following code online, everything has been set correctly, i reckon. The page return with "Success", but i haven't received any mail in my inbox. Was that Normal, or i should replace "localhost" by the my local smtp server's address, how do i know my smtp server address?
Thanks

<?php

ini_set("SMTP","localhost");
ini_set("sendmail_from","martin_ua@yahoo.com");

if (mail("martin_ua@yahoo.com","This is a test","This is the body","From: martin_ua@yahoo.com\r\nContent-type: text/plain\r\n\r\n"))
{
print "Success";
}
else
{
print "Failed";
}

?>
Reply With Quote
  #2 (permalink)  
Old 12-06-05, 06:26 AM
martin_ua martin_ua is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Anyone helps please

ANyone helps please
Reply With Quote
  #3 (permalink)  
Old 12-06-05, 07:49 AM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
Remove those two lines:

ini_set("SMTP","localhost");
ini_set("sendmail_from","martin_ua@yahoo.com");

And try it. If your server is set up correctly, php will interact with the sendmail and send the mail using default settings. You can also set the From address in the additional headers in the mail() function.

More info at the php.net site -- http://www.php.net/manual/en/function.mail.php (There's LOTS of samples of code)

Just a side note, not all servers come with a smtp server. IIS does not have a default one. At least, not to my knowledge. And, not all hosts allow it. You'll have to provide more info on your setup for a better answer. What OS is your server? Are you using IIS or Apache?
__________________
Yep, it's a signature...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbee question for sending emails Das Haas PHP 1 04-27-05 05:08 PM
Personal Mail Server Muzzargh Script Requests 0 07-27-04 09:02 PM
mail function causes server error thewhiteshadow PHP 1 11-13-03 03:40 PM
SMTP connect instead of using mail() spinicrus PHP 8 06-27-03 08:33 PM


All times are GMT -5. The time now is 06:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.