/    Sign up×
Community /Pin to ProfileBookmark

Upload HTML page, and send as an HTML email

Hi,

The following form allows the user to provide a subject for an email, and browse for an file. Upon clicking the “Send Email” button, how do I send the HTML page as an HTML email?

[CODE]<form action=”” method=”post” enctype=”multipart/form-data” name=”form1″>
<label>Subject:</label>
<input name=”subject” type=”text” id=”subject”>
<br>
<br>
<label>HTML Page:</label>
<input type=”file” name=”file”>
<br>
<br>
<input name=”send” type=”submit” id=”send” value=”Send Email”>
</form>[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jim_kellerSep 14.2008 — try this:

[code=php]

// Check to make sure we have a file
if ( !$_FILES['file']['name'] ) {
trigger_error( 'Sorry, you have to choose a file to upload', E_USER_ERROR );
}

if ( false === strpos($_FILES['file']['type'], 'html') ) {
trigger_error( 'Sorry, you can only upload HTML files', E_USER_ERROR );
}

if ( !($file_contents = file_get_contents($_FILES['file']['tmp_name'])) ) {
trigger_error( 'Error getting file contents', E_USER_ERROR );
}

$email_to = '[email protected]';

mail( $email_to, $_POST['subject'], $file_contents, "Content-type: text/htmlrn" );

[/code]
Copy linkTweet thisAlerts:
@F_DanialsauthorSep 20.2008 — Cheers for the reply!

How do I add an external CSS file to the HTML email? - Give it an absolute path? (http://www.mysite.co.uk/styles.css

Many Thanks,

F.Danials
×

Success!

Help @F_Danials spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...