473,806 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($Typ e);

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("$Recipien t, $Subject, $Message, $Headers");

//error check
if(!mail("$Reci pient, $Subject, $Message, $Headers"))
{
return FALSE;
}
else
{
return TRUE;
}
}
?>
Nov 22 '05 #1
6 1629
"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($Typ e);

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********@dom ain.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********@Dom ain.com>";

mail("$Recipien t, $Subject, $Message, $Headers");

//error check
if(!mail("$Reci pient, $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("$Recipien t, $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*****@invali d.invalid> wrote in message
news:BFA8BBEB.3 B5FF%in*****@in valid.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($Typ e);

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********@dom ain.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********@Dom ain.com>";

mail("$Recipien t, $Subject, $Message, $Headers");

//error check
if(!mail("$Reci pient, $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******@hotma il.com> wrote in message
news:11******** *****@corp.supe rnews.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($Typ e);

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("$Recipien t, $Subject, $Message, $Headers");

//error check
if(!mail("$Reci pient, $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("$Recipien t, $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
4967
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
2
2387
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. Meanwhile, this function permit to send mail anonyme ! (the sender is the apache user in fact)
1
1660
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 getting a "Relaying not explicitly allowed: fakeemail@fakedomain.com" response from the server however, when I try and set a recipient who is outside of my own domain. This makes my think that the From: address is somehow not getting sent to my...
2
2038
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) for(i=0; $i < $results; i++) { $row=mysql_fetch_array($result_query);
1
4791
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 reliable. I am not able to send email to my hotmail account but it does send to yahoo account. I'm not sure if there is something about hotmail that blocks emails for some unknown reason. If it goes to yahoo, it must go to hotmail. it doesn't even...
13
21341
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 to connect with my localhost mailserver? can anyone help me with this? thanks in advance..(^_^)
2
3685
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 function sendRequestPost() is in a file named header.php: function sendRequestPost(data) { // Open PHP script for requests MM_validateForm('email1','','RisEmail'); if (document.MM_returnValue) { <?php
1
2971
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 have tried to sent email to 4 to 5 email ids it is going for inbox only but i have a doubt if i send it to more than 100 email id it may go for spam
1
2396
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 the from, to, subject, and message text. So I wrote it up as a function and it sort of works, but I get a weird error. When it runs it inserts a "\t" tab character before each item during the send portion (which I can see when I turn on...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10617
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5545
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.