473,378 Members | 1,541 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,378 software developers and data experts.

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($email) {
$subject = 'Confirmation';
-----> $message = printConfirm($lang); <----
$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 1624
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
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...
5
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...
4
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...
4
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...
1
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...
6
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. ...
3
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...
11
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.