473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a Function inside the SendMail

Syl
Hi Group - I have a function to send an email to a client after they
have successfully submitted a form on my site. I have a 2nd function
that prints their input to the browser as a confirmation.

I'd like to be able to include that print function inside my mail
message like this :

function sendToClient($e mail) {
$subject = 'Confirmation';
-----> $message = printConfirm($l ang); <----
$headers = 'MIME-Version: 1.0' . "\r\n";
<snip>, etc
mail($to, $subject, $message, $headers);
}

This way I don't have to duplicate the output. The confirmation will
get printed to the browser AND the exact same content will be emailed.

When I executer this the email is blank.

Any expert ideas out there ?

Apr 11 '06 #1
2 1644
Remember that variables inside a function like this are treated as
local variables unless specified by the "global" keyword. Since I don't
see you defining the variable $lang in your function, it is empty and
thus no message is returned.

Fix - Either define the $lang as "global" in the function (that is if
$lang is defined outside the function) or the better way is to be sure
to pass the $lang variable as a parameter to this function.

Here is a resource link to what I am talking about... it is a variable
scoping issue I am guessing from what I see there.

http://ca.php.net/manual/en/language...bles.scope.php

Hope this helps :)

Apr 11 '06 #2
Syl
Hi Martry2 - thanks for going over this in detail.

The lang variable *is* actually global in scope, but there are other
parameters that are required that I did NOT make global - so this
should be the resolve!

thanks again!

Apr 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7687
by: lawrence | last post by:
We're installing a new server at the office and this will be the first server we set up from which we host our website. We got tired of dealing with Interland and decided to bring our hosting in-house. The guy doing most of the work struggled with sendmail for awhile and then gave up. Now he's installing Postit, or Postfix, or whatever it's called. Does the PHP mail function depend on sendmail, or can it use any mta software?
5
10242
by: A. Name | last post by:
Hello All! I'm a newbie to Linux and to PHP, so please be kind. I'm trying to tie into SendMail with some code and get the following error: Fatal error: Call to undefined function: mail() in /usr/local/apache/htdocs/development/test.php on line 317 I installed SendMail after PHP. I was told that it could be my problem and I would have reinstall PHP. Does this sound right to
4
3042
by: CoralineSage | last post by:
Hi All, I'm running a bulleting board in PHP and everytime a new user registers s/he is supposed to receive an email confirmation. After filling out the registration form and clicking on submit I get the following error message: Fatal error: Call to undefined function: mail() in /usr/local/apache2/htdocs/ubbthreads/ubbt.inc.php on line 212
4
4826
by: Data Goob | last post by:
This one has me stumped. How did SuSE disable the mail() function in their RPM'd version of PHP? ( This is their install-version of PHP with RPMs not what you download from PHP.net ) I have an application that emails people a message, and now having installed my PHP application on my customer's machine it doesn't work, giving an error message that the mail() function is not defined.
1
1913
by: tencip | last post by:
Hey everyone, We've got FreeBSD 5.3, with Sendmail running. All we want to do is to get sendmail to send emails to another server for actual outbound email. We've got a very basic php script which utilizes the mail() function, but for some reason, sendmail is never getting the command from PHP. So, we can successfully send email using sendmail from the command prompt, but when it comes to using the PHP mail() function, nothing
6
2286
by: sellam | last post by:
I just installed to a new server and am trying to iron out certain bugs. Right now I have a problem with the mail function. I always get a FALSE return value when I call the mail function. This same code was working on my old server. I've done research and spent hours trying to figure out why it won't work to no avail. Here's what I know:
3
1520
by: fluxent | last post by:
(Environment: RedHat Linux recent, Python 2.3.5) We have a batch processing script that on occasion needs to send out an email. We have a sendmail running locally. Sometimes we get a socket timeout on sending that email. Increasing the timeout to 30sec reduced but did not eliminate it. It seems to happen more often when sending to some addresses in the UK, but it's definitely not limited to that.
11
1982
by: Taras_96 | last post by:
Hi all, The PHP manual states that: "The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). " Does this mean that the sendmail binary is NOT needed on windows?
6
5202
by: phpmagesh | last post by:
Hi, I am using mail function in my php page, As soon i update the details, i have to send mail to the customer with the updated details, problem is when i send mail it simple through waring msg as: can anyone help me why such problem occurs, how to over come this problem.
0
9687
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
10257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
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
10029
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
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5467
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
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
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
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.