473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

function will not send mail!

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
6 1613
"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
"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
2
by: Groupe Eurower | last post by:
Hi, I would like contribute to the PHP development but i don't really know where i can submit my codes ! In fact, i'm a Web Hosting and i authorize the utilisation of the mail() function. ...
1
by: tzuccolo2001 | last post by:
I'm trying to send an email using the mail() function. I've carefully made use of the ini_set(SMTP, "mail.my.server") function to set my SMTP server and also to set my From: address. I'm still...
2
by: Bandul | last post by:
Hi everyone I am trying to send a e-mail using the mail() function. Now i try to send more than one data from mysql database so i must use example $results=mysql_num_rows($result_query)...
1
by: crescent_au | last post by:
I am developing a simple mailing system. This requires sending emails in HTML format to one or more recipient. I am currently using PHP's mail() function. It works alright but it doesn't seem...
13
Nert
by: Nert | last post by:
hello every one, i need help.. how can i use the mail() funtion in php? when ever i execute the mail function i continuesly receive this error message: what do i need to do in order for me...
2
by: sufian | last post by:
<input type="image" id="imageField" class="btn" src="<?php bloginfo('template_url'); ?>/media/global/btn-go.gif" onclick = "sendRequestPost(document.getElementById('email1').value);" /> The...
1
by: akuva | last post by:
I have to send more than 100s of email using a php code if i use mail function whether it will be sent to spam or inbox. If it is sent to spam which is the other way to send mass email from php. i...
1
by: Hunter | last post by:
I am writing a script that needs to send some emails. And I've used smtplib in the past and it is pretty easy. But I thought, gee it would be easier if I could just call it as a function, passing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.