Forum Moderators: coopster
Are there any known problems with the mail () function? I not, could someone please give me some advice as to what could be wrong
Thanks
Anyway, I ran in to this *exact* issue, and I found a little program called PHPMailer. It's awesome. There *is* an SMTP server on the client's server, but the tech guys refused to change the settings to allow relayed messages (most likely, they just didn't know *how* to do it - they had a funny way of disappearing when I had tech questions!) - PHPMailer allows you to set the username and password from the SMTP server in a separate file that gets called in by your current PHP Mail() form. So it authenticates all emails coming into the server - and it doesn't rewuire you to change any settings. It was really easy to use.
I used the program (you can get it for free at SourceForge) and I beefed it up a bit (which made things a *lot* easier) with a tutorial from PHPFreaks.com
Hope that helps ya!
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = email@example.com
The php script I have tried running is:
<?php
$to = "email@example.com";
$subject = "Test PHP email";
$body = "Message text here";
$headers = "From: email@example.com\n";
if(mail("$to,$subject,$body,$headers\n"))
{
echo "An e-mail was sent to $to with the subject: $subject";
}
else
{
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid";
}
?>
But, I always get the "There was a problem..." message.
Does it watter what email address i specify in sendmail_from? That is my email address? I want to use something like server@example.com but it doesn't exist so I thought it might not work.
I have QK SMTP Server 3, listening on port 25.
I have also tried disabling my firewall... But nothing seems to work
Does anyone have any suggestions as to why this won't work?
[edited by: eelixduppy at 5:23 am (utc) on Sep. 14, 2007]
The only problem is that it tells me it was sent, my smtp server receives the request, but the smtp server crashes on this error:
Message FROM: <email@example.com> TO: <email@example.com> directly fail! Connect fail: Socket Error # 10060 Connection timed out. Wait for retry...
The email address email@example.com is specified in my php.ini [mail function] - send_from
Does the address specified in php.ini have to, in some way, be associated with my smtp server?
Can i change it to a non-existant one, such as server@isp.co.za or something to that effect?
I am still trying to run the script:
<?php$to = "email@example.com";
$subject = "Test PHP email";
$body = "PHP is one of the best scripting languages around";
$headers = "From: email@example.com\n";if(mail($to,$subject,$body,"$headers\n"))
{
echo "An e-mail was sent to $to with the subject: $subject";
}
else
{
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid";
}?>
[edited by: eelixduppy at 5:24 am (utc) on Sep. 14, 2007]
Is there any way to implement some other way of sending - not via the localhost... There isn't a dedicated smtp server either. Is there perhaps a smtp server that anyone can route their email through? (eg maybe route the email through gmail using my credentials... or something to that effect)
Thanks
I've heard of people having issues with this before...but wouldn't you know it, I can't find any of my old links now. However, I did find this (I won't link it, I'll just copy what they said):
"Basic Procedure
Gmail allows you to forward incoming messages to any other e-mail address. Go to the Settings page and then to the Forwarding and POP tab. In the Forwarding option, set Gmail to forward all incoming mail to your regular e-mail account, and keep a copy in Gmail's inbox.
(In this explanation, I will assume your regular e-mail address is user@domain.com and your Gmail address is user@gmail.com, and I apologize to Mr. User over at Domain.com and Mr. User over at Gmail if they get any extra mail from people following the steps in this article too literally.)
Once that forwarding rule is set on Gmail, all incoming mail to user@gmail.com will get spam filtered and anything left over will be forwarded to user@domain.com, with a copy left at Gmail. But that doesn’t help you much yet, because people are still sending spam directly to your user@domain.com account.
Now, over at your user@domain.com's mail server, create a server-side filter to check the headers of any incoming e-mail. Have it forward to your Gmail account if it does not find the following in the header:
X-Forwarded-For: user@gmail.com user@domain.com
In English, the filter would be written: "Any mail that does not contain 'X-Forwarded-For: user@gmail.com user@domain.com' in the mail header should be forwarded to user@gmail.com".
Once this server-side filter is in place, only mail on its way back from user@gmail.com (already filtered for spam) will be passed to your user@domain.com account's inbox. Everything else will be forwarded on to user@gmail.com to be filtered and forwarded back. "
Perhaps the issue is that you don't have the routing set up in your Gmail account, and that's why it's failing.
Also, your socket error:
"Socket Error #10060
The technical message behind this error is:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
You should ensure that:
* You have entered the correct IP address.
* The Agent is not behind a network firewall which is blocking the connection.
* The Agent is connected to the Internet.
Please Note: If the Agent is installed on Windows XP, you must make sure you have configured the built-in firewall to allow incoming connections on port 7250."
Hope that helps you out :)