#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 1999
    Location
    DeKalb, IL 60115
    Posts
    7
    Rep Power
    0
    When sending email through perl, what do you have to do to enable HTML tags in the email?

  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    It's quite simple if you look at this script.

    #############################################
    #!/usr/local/bin/perl
    $email = 'webmaster@devshed.com';
    $youremail = 'your@email.com';
    open (MAIL,"|/var/qmail/bin/qmail-inject");
    print MAIL "Subject: HTML Emailn";
    print MAIL "From: DevShed.com <$email>n";
    print MAIL "To: miguelgarcia <$youremail>n";
    print MAIL "Content-type: text/htmlnn";
    print MAIL "<html><body><p>n";
    print MAIL "<blink>Hello</blink></p>n";
    print MAIL "</body></html>n";
    close (MAIL);
    print "Content-type: text/htmlnn";
    print "DONEn";
    ############################################
    The whole idea is that you are sending the BODY of your email in HTML, so place it right b4 the body of the message.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 1999
    Location
    DeKalb, IL 60115
    Posts
    7
    Rep Power
    0
    I tried the code above and the "Content-type: text/html" shows in my email as part of the content.

    I am using sendmail since I do not have qmail-inject installed on our server. Does sendmail not have the capability to send html formatted emails?
  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>I am using sendmail since I do not have..
    Simply change that line to:

    open (MAIL,"|/usr/sbin/sendmail -t");

    >>the "Content-type: text/html" shows in my email as part of the content..
    print MAIL "To: miguelgarcia <$youremail>n";
    print MAIL "Content-type: text/htmlnn"; # make sure this line is in this position
    print MAIL "<html><body><p>n";

    #if you are using M$ outlook, you might need to remove one newline as:
    print MAIL "Content-type: text/htmln";
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 1999
    Location
    DeKalb, IL 60115
    Posts
    7
    Rep Power
    0
    Yeah the problem was the extra "n" so now internet mail accounts and Microsoft email programs do recognize the html formatting.

    I realized after sending the mail, thats the way it goes, that AOL and Lotus Notes did NOT recognize the html tags. Does anyone have any ideas for thoose browsers or maybe a more universal format????

    Thanks for all help thus far.
  10. #6
  11. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>that AOL and Lotus Notes did NOT recognize the html tags.
    So your clients/members complain about that?
    Tell them go to http://www.aolsucks.com or block aol emails from registering. So AOL really can't read html email?
    Lotus Notes, I dun know about it.

    I suggest you not to send html emails if possible. Many people don't like to enable html email.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    16
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by miguelgarcia:
    When sending email through perl, what do you have to do to enable HTML tags in the email?
    [/quote]

    I send html mail as an attachment. Of course I use an established module for this:

    MIME::Lite

    to give you an idea how easy it is:

    attach $mail
    Type =>'text/html',
    Data =>$save_html;

    $save_html is the html version of the email I am sending. Go to CPAN and lookup the documenation for that module. I use it a lot.

    Peter




    ------------------
    Exercise Your Brain,Read a Book

IMN logo majestic logo threadwatch logo seochat tools logo