Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

MAIL::Sendmail Problem - Updated

by bilfurd (Hermit)
on Nov 07, 2003 at 18:47 UTC ( [id://305401]=perlquestion: print w/replies, xml ) Need Help??

bilfurd has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, All --

I created a script that reads information from a database, applies that information to address the e-mail and insert the user's name and password into the text of the message (doing an on-line survey for a client).

The code is very basic and has worked well on two different projects. The problem I have concerns the message text. The URL is hardcoded in the message text. The message text is assigned to a variable. The URL was encoded as

HTTP://www.somesite.com/somepage

but appears in a handful of messages as

HTTP://wwwsomesite.com/somepage

There are no special characters being read from the database.

I have not been able to find any pattern to the occurence.

Have any of you encountered this behavior? Any help understanding this would be appreciated.

Thanks!

=== U P D A T E ===

As requested...

use DBI(); use Mail::Sendmail; unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , '100.100.100.200'; $dbaxs = DBI->connect("DBI:ODBC:dsn=CLIENT_EMAIL") || die "Connection +died\n\n"; $Exe = "SELECT * FROM qryFeedLetter"; $qry = $dbaxs->prepare("$Exe"); $qry->execute() || die "\nBad SQL\n"; while (my $rw = $qry->fetchrow_hashref()) { $login = $rw->{'UsrLogin'}; $FName = $rw->{'UsrFName'}; $Supervisor = $rw->{'Supervisor'}; $EmlTo = $rw->{'UsrEmail'}; $subj = "Employee Satisfaction Survey"; $msg = "Dear $FName:\n\nYou are probably aware .. "; $msg .= ".. more text .. \nNOTE: In your survey, the word \"manage +r\" refers to $Supervisor. .. blah blah blah .. go to http://www.som +esite.com/somepage Your personal \"Log-In\" code is \"$login\". .. +more text here, then .. Thanks.\n\nVery sincerely,\n\nClient"; %mail = ( To => "$EmlTo", From => 'ClientSurvey <soembody@somesite.com>', Bcc => 'me@somesite.com', Subject => "$subj", Message => "$msg" ); sendmail(%mail) || die $Mail::Sendmail::error; print "\n\nLogged:\n", $Mail::Sendmail::log; } $dbaxs->disconnect();

Win XP, Perl v5.8

The text assigned to $msg is significantly longer than posted here

Thanks again

Replies are listed 'Best First'.
Re: MAIL::Sendmail Problem
by Paulster2 (Priest) on Nov 07, 2003 at 20:43 UTC

    I don't know for sure, but maybe the code is interpreting it as a typical way you bring seperate variables together (The technical term is slipping me).

    Question back at you, why don't you put the URL in a variable, that way it would be easy to change and find. Also you would be able to see what it looks like by printing it somewhere or something. I try to do this in seperate test code to make sure that I know what I am getting. I do realize that the URL is going to be static, but you may want to reuse the code for somethign else sometime, and finding the variables upfront and in technicolor may be of use. But then again, what do I know, I'm just a novice.

    Something else I have used successfully is when the need for double quotes are used for printing, try using a single quote on the outside. This works pretty good in most instances and there is less need to backslash everything. This makes the code cleaner to look at. I guess what I am trying to say is to try and format it some other way that should work and see if it does. Goes back to the There's more than one way... thing.

    Someone else may have a better input, but this is what I have for you for now. Hope it helps.

    Paul

      Thanks for your input, Paulster2

      As far as putting the URL in a variable, the message text changes a lot from project to project, and we use several different URLs. Usually, I get the message text from Big Boss or another project leader via e-mail. A little cut-and-paste with the message text, tweak the database calls, and fire.

      Hmmm... I did this code a few years ago using examples and did not use strict. I am going to fix that now, then perform a suitable act of contrition so I never forget to use strict again.

        Sounds like a good place to use a heredoc.

        You could also put the entire message in a flat file or something, then read it into a generic sending script. This would make it real easy to change everything. Again it's a cut and paste operation, but your PERL code wouldn't have to change every time that the boss says send.

        Paulster2

        Not a sermon, just a thought!

Re: MAIL::Sendmail Problem
by barrd (Canon) on Nov 07, 2003 at 19:06 UTC
    Hi bilfurd,
    Without seeing some relevant code this is almost impossible to answer. Variables don't just change themselves, there is some kind of substitution or transliteration going on here. Please post the relevant part/s and we might be able to help you out.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://305401]
Approved by sgifford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found