By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,088 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,088 IT Pros & Developers. It's quick & easy.

function will not send mail!

P: n/a
Hi all,

I've created the below function to automatically send me an alert in outlook
when someone completes various forms on my website.

The problem though is that mail reports that I have only 1 of the 3 required
parameters defined!

I have no idea where this is going wrong, because as far as I can tell I
have defined all 3 parameters! Can anyone spot the problem?

Regards
Tobierre
<?PHP
function alert_outlook($Type)
{
$Type = strtolower($Type);

switch($Type)
{
case 'newsletter':
$Subject = 'message subject one here';
$Alert = "Hi,\n Just thought you would like to know that there has been
another subscription to the newsletter!\n\n";
break;

$Alert = wordwrap($Alert, 65);
}

//set headers etc
$Recipient = "Auto Alerts<Au********@domain.com>";

$Message = "\n\n{$Alert}\n\n\n";
$Message .= 'Date: ' . date("l, js F Y") . "\n";
$Message .= 'Time: ' . date("H:i:s") . "\n";
$Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

$Headers = "FROM: Auto Mailer<Au********@Domain.com>\r\n";

mail("$Recipient, $Subject, $Message, $Headers");

//error check
if(!mail("$Recipient, $Subject, $Message, $Headers"))
{
return FALSE;
}
else
{
return TRUE;
}
}
?>
Nov 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Tobierre" wrote:
I've created the below function to automatically send me an alert in outlook
when someone completes various forms on my website.

The problem though is that mail reports that I have only 1 of the 3 required
parameters defined!

I have no idea where this is going wrong, because as far as I can tell I
have defined all 3 parameters! Can anyone spot the problem?


Try this (and see if you can spot the changes):

<?php
function alert_outlook($Type)
{
$Type = strtolower($Type);

switch($Type)
{
case 'newsletter':
$Subject = 'message subject one here';
$Alert = "Hi,\n Just thought you would like to know that there has been
another subscription to the newsletter!\n\n";
break;
default:
$Subject = 'no subject';
$Alert = '';
}

$Alert = wordwrap($Alert, 65);

//set headers etc
$Recipient = "Auto Alerts <Au********@domain.com>";

$Message = "$Alert\n\n\n";
$Message .= 'Date: ' . date("l, js F Y") . "\n";
$Message .= 'Time: ' . date("H:i:s") . "\n";
$Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

$Headers = "From: Auto Mailer <Au********@Domain.com>";

mail("$Recipient, $Subject, $Message, $Headers");

//error check
if(!mail("$Recipient, $Subject, $Message, $Headers"))
{
return FALSE;
}
else
{
return TRUE;
}
}
?>

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

Nov 22 '05 #2

P: n/a
"Philip Ronan" wrote:
mail("$Recipient, $Subject, $Message, $Headers");


Oops, that should be

mail($Recipient, $Subject, $Message, $Headers);

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

Nov 22 '05 #3

P: n/a
Hi phil,

Thanks for that. Got rid of the PHP mail parser warning, but even with your
suggestion it will still not send the e-mail! the error check returns
false!!

Got another suggestion? as I'm fresh out today

Tobierre

<in*****@invalid.invalid> wrote in message
news:BFA8BBEB.3B5FF%in*****@invalid.invalid...
"Tobierre" wrote:
I've created the below function to automatically send me an alert in
outlook
when someone completes various forms on my website.

The problem though is that mail reports that I have only 1 of the 3
required
parameters defined!

I have no idea where this is going wrong, because as far as I can tell I
have defined all 3 parameters! Can anyone spot the problem?


Try this (and see if you can spot the changes):

<?php
function alert_outlook($Type)
{
$Type = strtolower($Type);

switch($Type)
{
case 'newsletter':
$Subject = 'message subject one here';
$Alert = "Hi,\n Just thought you would like to know that there has been
another subscription to the newsletter!\n\n";
break;
default:
$Subject = 'no subject';
$Alert = '';
}

$Alert = wordwrap($Alert, 65);

//set headers etc
$Recipient = "Auto Alerts <Au********@domain.com>";

$Message = "$Alert\n\n\n";
$Message .= 'Date: ' . date("l, js F Y") . "\n";
$Message .= 'Time: ' . date("H:i:s") . "\n";
$Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

$Headers = "From: Auto Mailer <Au********@Domain.com>";

mail("$Recipient, $Subject, $Message, $Headers");

//error check
if(!mail("$Recipient, $Subject, $Message, $Headers"))
{
return FALSE;
}
else
{
return TRUE;
}
}
?>

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/

Nov 22 '05 #4

P: n/a
Hi Phil,

Thank you, thank you

Tobierre
"Tobierre" <No******@hotmail.com> wrote in message
news:11*************@corp.supernews.com...
Hi all,

I've created the below function to automatically send me an alert in
outlook when someone completes various forms on my website.

The problem though is that mail reports that I have only 1 of the 3
required parameters defined!

I have no idea where this is going wrong, because as far as I can tell I
have defined all 3 parameters! Can anyone spot the problem?

Regards
Tobierre
<?PHP
function alert_outlook($Type)
{
$Type = strtolower($Type);

switch($Type)
{
case 'newsletter':
$Subject = 'message subject one here';
$Alert = "Hi,\n Just thought you would like to know that there has been
another subscription to the newsletter!\n\n";
break;

$Alert = wordwrap($Alert, 65);
}

//set headers etc
$Recipient = "Auto Alerts<Au********@domain.com>";

$Message = "\n\n{$Alert}\n\n\n";
$Message .= 'Date: ' . date("l, js F Y") . "\n";
$Message .= 'Time: ' . date("H:i:s") . "\n";
$Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

$Headers = "FROM: Auto Mailer<Au********@Domain.com>\r\n";

mail("$Recipient, $Subject, $Message, $Headers");

//error check
if(!mail("$Recipient, $Subject, $Message, $Headers"))
{
return FALSE;
}
else
{
return TRUE;
}
}
?>

Nov 22 '05 #5

P: n/a
what you can do, do this way.
I hope it will work.
$is_sent = mail("$Recipient, $Subject, $Message, $Headers");

if ($is_sent === TRUE){
echo "Sent successfully";
}else{
echo "Got problem in sending an email.";
}
Good luck.

Nov 22 '05 #6

P: n/a
correction.

$is_sent = mail($Recipient, $Subject, $Message, $Headers);
if ($is_sent === TRUE){
echo "Sent successfully";
}else{
echo "Got problem in sending an email.";
}

Nov 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.