Perl breaking up URLs ???

Posted on 2006-05-26
Last Modified: 2010-03-05
I'm sending emails (i've tried MIME and SENDMAIL) both do the same on certain email clients...

I send an email with a link, and here below are some examples of the url breaking d=1148406418.46167
and! .html?id=1146681613.77319

weird how it stuck an ! in one, and put a space in both!?!?!

Any ideas, what could be causing this, the code looks fine. One person was on Groupwise, the other I'm not sure.
Question by:jmingo
    LVL 39

    Expert Comment

    How are you getting the link text?  reading from a text file? DB? hard coded?

    Could you post the relevant code?


    Author Comment

    thanks for the response. here is some of the code sending the email with link.

    $r=time . '.' . $$  ;

    my @mailnames=split(/ *, */,$email) ;
    foreach(@mailnames) {

    $emaillink = "$r";
    $emaillinklow = "$r&highspeed=no";

    $message = "<html><head><title>e-maill</title></head><style type=\"text/css\">body, td, input, select, textarea { font-size: 13px; font-family: Trebuchet MS,  Verdana, Arial, Sans-Serif; }</style><body bgcolor=#FFFFFF marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><table border=0 cellpadding=0 width=600 cellspacing=0><tr><td valign=top align=left><img src=\"$background.jpg\"></td></tr><tr><td valign=top align=left><table border=0 cellpadding=3 cellspacing=3><tr><td align=left valign=top>$newemailcontent<br><br><a href=\"$emaillink\"><b>$link</b></a><br><a href=\"$emaillinklow\"><b>$link - For Dial-up</b></a><br><br>$newsignature</body></html>";

    open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

    print SENDMAIL "to: $_\n";
    print SENDMAIL "from: $fromname <$fromemail>\n";
    print SENDMAIL "Reply-to: $fromname <$fromemail>\n";
    print SENDMAIL "Return-Path: $fromemail\n";
    print SENDMAIL "MIME-Version: 1.0\n";
    print SENDMAIL "subject: $subject\n";
    print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";
    print SENDMAIL $message;
    print SENDMAIL "\n\n";

    Author Comment

    Both users are using groupwise i have found out.
    LVL 8

    Expert Comment

    print $message to the screen and see what it looks like before sending in the email.

    Author Comment

    perl_diver: i'll try that.

    if i email two people (for ex., who uses outlook (no groupwise) will get it fine but the groupwise user will have the url broken up it seems.

    so i'm quite sure its a groupwise thing.

    any ideas??
    LVL 8

    Expert Comment

    Are you reffering to Novell GroupWise? If so maybe that's where you should be asking this question:

    If not, I don't undserstand what is besides a website which points to Novell's GroupWise Product information website. I can't see how perl has anything to do with this problem but maybe somenone else will.

    Author Comment

    yes its novell group wise.. thanks, i'll ask the question there.
    LVL 6

    Expert Comment

    Try using URI::Escape

    use URI::Escape;

    $safe_r = uri_escape($r);

    $emaillink = "$safe_r";
    $emaillinklow = "$safe_r" . '&highspeed=no';

    Did you notice that second scalar $emaillinklow has been split into two parts. This is done as & is reserved operatior in perl and is used to call subroutines.

    Hope this helps.

    LVL 8

    Expert Comment

    the & symbol has no special meaning in a double-quoted string, a little test shows that:

    my $r = time . '.' . $$;
    my $emaillinklow = "$r&highspeed=no";
    print $emaillinklow;
    LVL 26

    Expert Comment


    Do you know if they are seeing an HTML formatted email or if they see the HTML code in their emails?
    Also, you use $link in the $message scalar, what's the content of $link?

    Author Comment

    i think the solution was to put some \r\n's in the code. what was happening i think is the code was just all strung together without any line feeds, so some servers were putting in line feeds and ! when it hits like 998 characters or something like that.

    Author Comment

    solution provided above

    LVL 1

    Accepted Solution

    Closed, 25 points refunded.

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Remove Malware code from PHP file 6 49
    Perl - Mawk 2 56
    Perl output collect 7 63
    git fat pull happens nothing in centos 6.3 python 2.6.6 33 172
    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now