mail() question
Moderator: General Moderators
mail() question
Hi all, I have the following code
...
$success = mail($emailaddy, $subject, $message, $headers);
if ($success)
echo "The email to $emailaddy from $from was successfully sent<p>";
else
echo "An error occurred when sending the email to $emailaddy from $from <p>";
I assume that is all correct, but when it is executed I get the error:
Warning: Failed to Connect in C:\blahblah\insertcal.php on line 36
An error occurred when sending the email to (sent email) from (from email)
I'm guessing the error is in that I don't have SMTP server set up correctly (i'm testing on my local machine atm). I have looked on the net for suggestions etc and haven't found much. I have to set up my php.ini file? Any suggestios on what I need to do to setup the SMTP properly (if that is indeed the problem) would be appreciated, thanks in advance.
...
$success = mail($emailaddy, $subject, $message, $headers);
if ($success)
echo "The email to $emailaddy from $from was successfully sent<p>";
else
echo "An error occurred when sending the email to $emailaddy from $from <p>";
I assume that is all correct, but when it is executed I get the error:
Warning: Failed to Connect in C:\blahblah\insertcal.php on line 36
An error occurred when sending the email to (sent email) from (from email)
I'm guessing the error is in that I don't have SMTP server set up correctly (i'm testing on my local machine atm). I have looked on the net for suggestions etc and haven't found much. I have to set up my php.ini file? Any suggestios on what I need to do to setup the SMTP properly (if that is indeed the problem) would be appreciated, thanks in advance.
server running on XP
php.ini (located in server/php)
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
Thanks
php.ini (located in server/php)
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
Thanks
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Check the output of
if you're worried that you're editing the wrong php.ini, it'll tell you which one it is getting its values from.
Mac
Code: Select all
<?php phpinfo(); ?>Mac
Ok I now have it sending mail...but (lol) it seems to be sending the same message over and over again? any ideas on why and how to stop it? (stopping the server will stop it ?) here is my code
$equery = "SELECT email_address, first_name FROM users WHERE first_name = '$applies_to'";
$result = mysql_query($equery);
$enum=mysql_num_rows($result);
$emailaddy = "email@emailaddress";
$first_name=mysql_result($result,"first_name");
$from = "another@email.com";
$subject = "New event added $title";
$message = "blahblah blah message here";
$headers = "From: $from\r\n";
$success = mail($emailaddy, $subject, $message, $headers);
if ($success)
echo "The email to $emailaddy from $from was successfully sent<p>";
else
echo "An error occurred when sending the email to $emailaddy from $from <p>";
Thanks for your ongoing help
$equery = "SELECT email_address, first_name FROM users WHERE first_name = '$applies_to'";
$result = mysql_query($equery);
$enum=mysql_num_rows($result);
$emailaddy = "email@emailaddress";
$first_name=mysql_result($result,"first_name");
$from = "another@email.com";
$subject = "New event added $title";
$message = "blahblah blah message here";
$headers = "From: $from\r\n";
$success = mail($emailaddy, $subject, $message, $headers);
if ($success)
echo "The email to $emailaddy from $from was successfully sent<p>";
else
echo "An error occurred when sending the email to $emailaddy from $from <p>";
Thanks for your ongoing help