473,569 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending an E-mail (Code Included with post)

I know that in order to send an e-mail using Perl there must be a '\'
in front of the '@' symbol. For example department\@com pany.com. And
it works.

The problem that I am having is that we have many customers whom we
need to direct towards their own personal online order form. For some
reason when I try to place the '\' in front of the '@' symbol it does
not work.

For example pe****@isp.com. In order to send them an e-mail we need to
place the to have their email address take the form of
person\@isp.com .

However when i use the substr function the address remains the same.
substr(pe****@i sp.com, $where, 1) = "\@";
# attempt to insert '\' before '@'

The email address remains pe****@isp.com even after using substr.

Can anyone help me out with this?

A more detailed coding segment is below (it's not long).
#!/usr/bin/perl -w
use CGI qw(:all);
print "Content-type: text/html\n\n";

$EmailAddress = param("textEmai lAddress");
# From Text box on prev. page

print "EmailAddre ss is currently $EmailAddress";
# Check if email received

$where = index($EmailAdd ress, "@");
# Find the '@' symbol in the e-address

if ($where != -1) # If '@' symbol is in the e-address then
{
print "@ symbol found";
# Check to see if correct

substr($EmailAd dress, $where, 1) = "\@";
# Insert "\" before the "@" symbol in the EmailAddress

print "EmailAddre ss is now $EmailAddress";
# Check the current value of EmailAddress
}
else # If '@' symbol is not in the e-address then
{
print "@ symbol not found";
# Check to see if correct

print "where equals $where";
# Check to see if correct
}

open(MAIL, "|/usr/sbin/sendmail -oi -t"); #Sending the email
print MAIL <<EOM;
From: department\@com pany.com
To: $EmailAddress
Subject: "Your Order Form"

Here is your order form
EOM
close(MAIL);
Jul 19 '05 #1
2 9935
Michael wrote:
I know that in order to send an e-mail using Perl there must be a
'\' in front of the '@' symbol. For example
department\@com pany.com. And it works.

The problem that I am having is that we have many customers whom we
need to direct towards their own personal online order form. For
some reason when I try to place the '\' in front of the '@' symbol
it does not work.


You seem to have got most of it wrong, I'm afraid.

You need to escape the '@' character only in a double-quoted context
in order to prevent interpolation:

my $recemail = "you\@example.c om";

or

print MAIL <<EOM;
From: me\@example.com
To: $recemail
....

but once stored in a variable, the '@' character shall normally not be
escaped.

If you do:

my $recemail = "you\@example.c om";
print "$recemail\ n";

it outputs:
yo*@example.com

You can skip the backslash all through if you assign variables using
single-quotes instead of double-quotes:

my $recemail = 'yo*@example.co m';

HTH

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2
Michael wrote:
I know that in order to send an e-mail using Perl there must be a '\'
in front of the '@' symbol.
Certainly not, why would Perl impose such an odd requirement?
Maybe you are confusing the situation with an at sign inside a double-quoted
string, which must be escaped to not be interpolated as an array?
Like in "fo*@bar.co m" where because of the double quotes Perl will try to
interpolate @bar as the array @bar?
For example department\@com pany.com. And it works.
I doubt it. This is most likely not the email address you mean. Or do you
really want to send the email to 'department\'
The problem that I am having is that we have many customers whom we
need to direct towards their own personal online order form. For some
reason when I try to place the '\' in front of the '@' symbol it does
not work.
[code snipped] substr($EmailAd dress, $where, 1) = "\@";
# Insert "\" before the "@" symbol in the EmailAddress


Nope, you don't. The backslash inside the double quoted string simply tells
Perl to not interpolate the array but to take the at sign literally. In
other words the "\@" denotes just one at sign without any leading backslash.

You may want to read up on "Quotes and quote-like operators" in "perldoc
perlop".

jue
Jul 19 '05 #3

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

Similar topics

1
14497
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the headers). I can see this because I'm running Ethereal and watching the packets. I'm defining the packets as shown below: $text_msg = "Hello,...
1
6942
by: Tim Black | last post by:
My application requires sending a large piece (~2MB) of data to several devices on a network via TCP sockets. I have experimented with different methods for doing this and this has raised some questions about the implementation of Python sockets. (both methods use blocking sockets) Method 1: Calls socket.sendall(data) for each device in...
3
4617
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data and then fires a datareceived event. Within the waitingloop there is a timeout function, but I want the the 'last-time-socket-used' variable set...
2
3034
by: anonymous | last post by:
Hi, I'am sending an xml string to a web service(which is written in c#) using the microsoft web services behavior. When I check this string from the web service I observed that some of the charaters have been replaced. e.g "<" is replaced with "%3C", ">" is replaced with "%3E"
2
2754
by: Ebrahim | last post by:
Does any one have any suggestion of Sending Files over a Network ? using TcpClient class in C#. I need suggestions on transferring huge files ( > 5MB) reliably over the stream . Also any kind of files could have to be transferred .ie Exe , mp3 , dat .. any kind . Do i need to convert these files ? When i normally send text files i convert...
4
3115
by: Winston Nimchan | last post by:
Hi: I'm currently developing a socket application and would like to precede the data being sent with a 4 byte message length header (bin4). Can anyone help Regards Winston
17
2877
by: Bonj | last post by:
Right guys. (I would like a solution to this in VB6 as this is what our needy app is written in, but any solutions that involve .NET would be much appreciated likewise as I could instantiate them, otherwise please forgive the crossposting.) I'm sure I've seen posts here before criticising the practice of automating outlook for the...
3
11321
by: Sells, Fred | last post by:
I'm using MSW XP Pro with Python 2.4 to develop but production will be Linux with Python 2.3. (could upgrade to 2.4 if absolutely necessary) I can also switch to Linux for development if necessary. I am writing some python to replace proprietary software that talks to a timeclock via UDP. The timeclock extracts the sending port from the...
0
1852
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by one,then whethere we can show the progress of each file sending to server in progress bar. so that the FTP clients can see the progress of file...
0
7697
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...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
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...
1
7672
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...
0
7968
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...
0
5219
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
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
0
937
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...

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.