OriginalSunny Posted April 14, 2006 Share Posted April 14, 2006 Hi,I am trying to send an email in php using the mailsend function. The code i am using is:<?php$to = "manjl@hotmail.com";$subj = "test";$mess = "This is a test of the mail function";$headers = "From: hi@mycompany.com\r\n";$mailsend = mail($to,$subj,$mess,$headers);?>It doesnt seem to be working??? What am i doing wrong??Is there something i need to change in the php.inc file?Currently in my php.ini file i have this:[mail function]; For Win32 only.SMTP = localhost; For Win32 only.sendmail_from = me@localhost.com Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/ Share on other sites More sharing options...
Yesideez Posted April 14, 2006 Share Posted April 14, 2006 If you use the search function you'll find your question has been answered many times over. Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/#findComment-26978 Share on other sites More sharing options...
wildteen88 Posted April 14, 2006 Share Posted April 14, 2006 You need to point PHP to a SMTP sever. The address is usally like smtp.hostname.com. Usually you your ISP deals with an SMTP server so tehir customer can send and recieve emails with thier account. If your ISP has an smtp server then use the address for that smtp server and PHP should be able to send an email through the smpt server you specify.localhost which is your PC won't have an SMPT server to send emails. Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/#findComment-26981 Share on other sites More sharing options...
OriginalSunny Posted April 14, 2006 Author Share Posted April 14, 2006 [!--quoteo(post=364804:date=Apr 14 2006, 10:41 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 14 2006, 10:41 AM) [snapback]364804[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to point PHP to a SMTP sever. The address is usally like smtp.hostname.com. Usually you your ISP deals with an SMTP server so tehir customer can send and recieve emails with thier account. If your ISP has an smtp server then use the address for that smtp server and PHP should be able to send an email through the smpt server you specify.localhost which is your PC won't have an SMPT server to send emails.[/quote]So from what i understand i am unable to send emails until the website is up and running on a server(the internet as a web page). Or do i not quite get it? and do i need to find out the name of the SMTP server?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/#findComment-27004 Share on other sites More sharing options...
freakus_maximus Posted April 14, 2006 Share Posted April 14, 2006 If you are wanting to test your script locally (not that I have done this, but something to look into) the current version of XAMPP comes with an application called Mercury Mail. This appears to allow you to setup a local mail server. Again, I have not had a need to do this, so cannot provide any help, other than pointing you in that direction if you need to do something like that. Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/#findComment-27007 Share on other sites More sharing options...
wildteen88 Posted April 14, 2006 Share Posted April 14, 2006 You can send emails but you just need an address to an SMTP server. You dont have to have your site hosted by a webhost to send an email. You just go to find a public SMTP server that you can send emails through without having to sign into the SMTP server. Usually ISPs (Internet Service Provider - the company you pay to use the Internet) use POP/SMTP so their customers can send/recieve emails.You should be able to get an address to your ISPs SMTP server so you can send emails through PHP to it. But if the SMTP server requires athenitication then you wont be able to use the mail server.I use my ISPs mail server which is smtp.ntlworld.com - however I believe you can only send emails through NTLs SMTP server unless you're an NTL customer but you can try. Just copy and paste that into your php.ini to replace[b]SMTP = localhost [/b]to:[b]SMTP = smtp.ntlworld.com [/b]Save your php.ini and restart your server software (IIS, Apache etc). Quote Link to comment https://forums.phpfreaks.com/topic/7410-email-function-not-working/#findComment-27010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.