Jump to content

Email function not working


OriginalSunny

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.