Jump to content


Photo

Email function not working


  • Please log in to reply
5 replies to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 14 April 2006 - 03:19 PM

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


#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 14 April 2006 - 03:37 PM

If you use the search function you'll find your question has been answered many times over.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 April 2006 - 03:41 PM

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.

#4 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 14 April 2006 - 04:40 PM

[!--quoteo(post=364804:date=Apr 14 2006, 10:41 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 14 2006, 10:41 AM) View Post[/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.

#5 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 14 April 2006 - 04:51 PM

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.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 April 2006 - 04:53 PM

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
SMTP = localhost
to:
SMTP = smtp.ntlworld.com

Save your php.ini and restart your server software (IIS, Apache etc).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users