Jump to content

Archived

This topic is now archived and is closed to further replies.

OriginalSunny

Email function not working

Recommended Posts

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

Share this post


Link to post
Share on other sites
If you use the search function you'll find your question has been answered many times over.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.