CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Sending Mainl in HTML format using SENDMAIL...

 



Rivotti
User

Apr 18, 2000, 9:16 AM

Post #1 of 10 (1466 views)
Sending Mainl in HTML format using SENDMAIL... Can't Post

Hi:

I'm trying to understand how to send a mail in html format. I thought that

open (SENDMAIL, ...
...
print SENDMAIL <<HTML;
# html code
HTML
...
close (SENDMAIL);

should do it. But I was wrong... Frown . It sends me all. including the code. I know this is possible because I've allready seen it in the past.

Rivotti


Rivotti
User

Apr 17, 2000, 10:24 PM

Post #2 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi Jasmine:

You sure help me a lot. Smile
Thanks again for the help.

Rivotti


Jasmine
Administrator / Moderator

Apr 18, 2000, 9:24 AM

Post #3 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Check out an article in this month's issue of the learning center -- "HTML in E-Mail with Sendmail" at http://tlc.perlarchive.com/0004/03.shtml


Cure
User

Apr 18, 2000, 12:38 PM

Post #4 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi

Example

open (MAIL, "|$sendmail -t") &#0124; &#0124; die "Can't open mailprogram $!\n";
print MAIL <<END_OF_MAIL;
To: you\@me.net
From: hi\@perl.com
Subject: perl
Content-type: text/html\n\n
<html><body>
<font color=blue>I Love Perl</font>
</body></html>

END_OF_MAIL
close (MAIL);


Cure



[This message has been edited by Cure (edited 04-18-2000).]


Rivotti
User

Apr 19, 2000, 2:12 AM

Post #5 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi Cure: Smile

Thanks. This can be done?
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

# mail.txt
Dear Sr.

A lot of text...

# mail.cgi
...
$mail_txt="mail/mail.txt";
open (INFILE,"<$mail_txt");
$text=<INFILE>;
close(INFILE);

open (MAIL, "|$path -t");
print MAIL <<MESSAGE;
To: $to
From: $form
Subject: $subject
$text
MESSAGE
close (MAIL);
...
</pre><HR></BLOCKQUOTE>

Just two more things:

- It's really important to use "exit" at the end of a program? ( I normally dont use it )

- How to print a multiline string?

Thanks again
Rivotti

[This message has been edited by Rivotti (edited 04-19-2000).]


Rivotti
User

Apr 19, 2000, 8:38 AM

Post #6 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi again:

I was thinking... is it possible to send a mail to several addreses using sendmail? How to get several addresses using a Form input tag and then validate the string?

Rivotti


Cure
User

Apr 19, 2000, 6:46 PM

Post #7 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi

To e-mail everybody in your database.txt(all your e-mail visitors)

open (CURE,"<database.txt") or die "couldnt open database.$!";

chomp,push @database_array,$_ while (<CURE> );
close(CURE);
foreach $to(@database_array) {

next if $to =~ /^\n/;
open (MAIL, "|$sendmail -t") &#0124; &#0124; die "Can't open mailprogram $!\n";
print MAIL <<END_OF_MAIL;
To: $to
From: $you
Subject: Perl
Content-Type: text/html\n\n

<html><body>
<font color=blue>I Love Perl</font>
</body></html>

END_OF_MAIL
close (MAIL);

}


Cure


Cure
User

Apr 19, 2000, 6:50 PM

Post #8 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

to get info from a Form input tag named email and then validate the e-mail.

use CGI;
$q = new CGI;

if ($q->param('email')!~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
print "invalid e-mail address\n";
}


Cure



Cure
User

Apr 19, 2000, 10:47 PM

Post #9 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

use CGI;
$q = new CGI;

$email = $q->param('email'); # the name of your input tag needs to be named email and there needs to be a space in between the e-mail address in your input tag from the form

@email_array = split ' ',$email;


Cure


Rivotti
User

Apr 20, 2000, 1:04 AM

Post #10 of 10 (1466 views)
Re: Sending Mainl in HTML format using SENDMAIL... [In reply to] Can't Post

Hi Cure, Thanks again. Smile

Can you explain better the regular expressions? I would like to understand it.

After the validation, how to send mail for each mail in the form input box? I'm not getting the mail info from a file. The idea is to put several E-mail addresses in a input box and then the program send a mail for each address inserted.

Thanks for all the help
Rivotti

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives