Send Email on localhost
I'm trying to setup being able to use the mail() function on localhost as using free hosting all the time is a pain when the ftp connection keeps dropping and it takes hours to do just a simple bit of code.
I've done some searching and apparently it's possible to do this by changing the php.ini file to use the smtp connection of the ISP. My ISP is Virgin Media so I tried to use smtp.virginmedia.com which I found from their website but it seems unable to connect to this. I also read that it was possible to use your own email account and as I have a hotmail.com account I tried to use the live smtp however it gives an error that basically translates to needing a secure connection.
If anyone has managed to do this I would appreciate some help to get this working. Thanks
Just as an update: I've tried to use something called Argosoft Mail Server .NET which I understand is quite a popular mail server to use however I keep getting this error: SMTP server response: 510 User not local. We don't relay in *file name*.
I looked this problem up and people keep mentioning a tickbox that isn't there anymore called authentication not required if local or something like that.
If I need to use SMTP, I normally use the PHPMailer class, which comes with its own SMTP class. Here's one of their sample code pages showing an example of using SMTP: http://phpmailer.worxware.com/index.php?pg=examplebsmtp
Thanks for your reply I would certainly give this a try. I'd just like to use something that I can use the mail function on without having to upload the website to a free host. I've also been looking at the mail package in PEAR but I'll try this first
Either a brand new version has just come out of the examples haven't been updated as none of them seem to work. I've had a look elsewhere however but I keep getting this error:
Notice: Undefined variable: from in C:\wamp\www\phpmailer\phpmailer.inc.php on line 259
However in my code I am specifying a From value. Here is the source code for a simple test file:
$mail = new PHPMailer();
$mail->Host = "smtp.live.com";
$mail->From = "email@example.com";
$mail->Subject = "Test";
$mail->Body = "Test Body Message";
echo "Message was not sent";
echo "Message successfully sent";
From the example, it looks like you should be using the SetFrom() method:
That method no longer exists however I think I've fixed it but I had to edit the phpmailer code. Instead of the $header->$from code I've changed it to $this->From. It doesn't show an error anymore at least.
Still I can't send an email. I've been trying to use my hotmail account to send an email but it still won't work and I've tried all kinds of tutorials etc for making phpmailer work with PHP but they all seem to be outdated. Perhaps I should just download a mail server and try that instead?
Are you sure you got the PHP 5 version? I ask because it looks like the download link on their site goes to the PHP 4 version at sourceforge. Try this page: http://sourceforge.net/projects/phpm...Mailer%20v5.1/ to get PHPMailer 5.1, or if you want 5.0 (which is the last one I downloaded and has worked fine for me), go to http://sourceforge.net/projects/phpm...us%20Versions/.
Ah thank you you're right I must have been using an old version even though I clicked for PHP 5. Thank you for the link perhaps this will help solve some of the confusion
Finally managed to get it working and an email was successfully sent. Thanks for your help
Sweet. I used their contact form to tell them about the bad links. I hope their email script worked.
Haha that would be controversial if it didn't .
Just while we're on the subject of sending email in PHP instead of making a new thread do most emails sent from free hosting end up in Hotmail's junk folder? It's just that while I am intending to use email on localhost for the time being I've been writing scripts on a free account from 000 web host. The only thing is if I don't include any headers the email goes straight into inbox as "Nobody" but as soon as I start including header information it will always get sent to the junk folder and flagged as "suspicious"
Spam filters are an arcane mystery which I have not studied much. Your message could be filtered based on email headers (or lack thereof), suspicious content in the body or subject, and the IP address of the sending host (and maybe forwarding hosts in between?). So if you are on a shared host that is noted for hosting accounts that spam, that in and of itself might be a problem.
But like I said, it's not something I'm any sort of expert on, and there is lots of information (and probably misinformation) out there on the web to sift through.
I'm guessing it's some sort of error in my headers due to the fact that when I take the headers out the email will always land in the inbox which seems a bit strange to me.
The headers just contain the usual MIME-Version, Content-type , charset and From and I've checked them over and they are all correct in fact I think I copied them from somewhere else as they are pretty much all the same except for the From which is just my email address.
I registered an account just to tell you guys that you are awesome for solving this problem for me! By the way, phpmailer's website still has not corrected their download link for the php 5 version of phpmailer. Evidently their contact form either doesn't work or they don't check their messages.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)