Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Email 2

Status
Not open for further replies.

audiopro

Programmer
Joined
Apr 1, 2004
Messages
3,165
Location
GB
I am trying to send html email from a remote server.
The email is sent ok without the image html but can someone tell me if this, or a variation should work or do I need to find an alternative solution.
Code:
open( EZMAIL, "|/bin/easymail -t" ) or return 1; 
print EZMAIL "Content-Type: text/html\n";
print EZMAIL "From: welcome\@sourcename.co.uk\n";
print EZMAIL "To: cli1\@targetname.co.uk\n"; 
print EZMAIL "Subject: some subject\n\n";
print EZMAIL "<img src='[URL unfurl="true"]http://www.imagelocat.co.uk/icons/upgrade.gif'[/URL] alt='testpic'>\n";
print EZMAIL "Some content.\n";
close (EZMAIL);


Keith
 
There is no reason to have this in your code and it looks wrong anyway:

Code:
    $msg->attach(
        Type => 'image/gif',
        Id => '[URL unfurl="true"]http://www.XXX/emailhead.gif',[/URL]
    );

Since you are using the URL of the image in the body of the message it will be displayed like any other image is when viewed in a browser while online.



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks - that did the trick.
I did fork the process and got it to work but I was sure that there was a better solution.
Should I be able to put a full HTML document in the body section?
I want to CSS code the email but would rather avoid inline clutter and use a style sheet. Up to now, any attempts to insert a header section has stopped the email being sent.

Keith
 
You can author emails messages the same as web pages. But there is no gaurantee the recipient will view the email as you hope. There are too many variables in between you sending the email and them recieving it.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I think I will keep it simple as a picture in the email is a vast improvement on the previous text only.
I would like to set the text to something other than the default Times New Roman though, can this be done reliably?

Keith
 
Use any common font-face and it should be no problem.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
audiopro, have you tried using the HTML:Template module in conjunction with this?

That's how I get my HTML email and PERL code separated.

Write the email as normal html, use the template module to merge any data required to the html email template, pass the output from the template module as the body part to the mailer routine instead of printing it to screen and bob's your uncle.

I send HTML email with PDF attachments , which are even generated on the fly with a screen capture PDF ASP program all day, everyday.

Do you usually write your HTML in your perl code? if so it might be worth looking at the HTML:Template module for all HTML->PERL code separation.

Once you master it , you'll never go back ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I read a lot of the HTML in from external files with place holders for variables.
How do you tackle the situation where you have say, a table which you populate individual rows of cells with vars on the fly?
I usually put the html in and then loop as much as possible.
keeps it fairly neat but it would be good to get rid of all the HTML.



Keith
 
you use HTML:Template.

It's an awesome module for code separation, you can create loops to build hrml tables of data , use global vars, loops within loops.

Once you start using it, you never look back :-)

You simply add a few extra bits in the HTML and then when the module merges the tamplate it replaces the template vars (like your place holders) with the data and you result in the finished HTML, much more powerfull and better than doing the place holder thing.

If you want , i'll teach you the basics, but you need to install the module first :-)



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top