HTML format for joomla sendmail - email

I want to change the joomla plain text email format to HTML format, so when user get email from my joomla site will receive a nice looking html formated email. Anybody can assist me how to do this? Any core hack would be OK. Thanks

here is what u need to do, there is flat that tells joomla mailer that content is in html
jimport('joomla.mail.mail');
$user = JFactory::getUser();
$user_email = $user->email;
$mailer = JMail::getInstance();
$mailer->setSender('no-replay');
$mailer->addRecipient($user_email);
$mailer->isHTML(TRUE); <--- here is flag
$mailer->setSubject('subject');
$html= array();
$html[] = '<div style="background: red"> hello world</div>';
$mailer->setBody(implode("\n", $html));
$mailer->Send();

If you are referring to the Mass Mail system in the Joomla backend, then there is an option saying "send in HTML mode". Else I would recommend using a different component.

Related

Centralised mailto email link

Is there a way to centralise a typical mailto html string so that the email address can be updated once instead of multiple times across the pages themselves?
Send Mail
Using PHP with $_SESSION you can have a $mail variable set that you spread trough all your webpages.
Example :
index.php
<?php
session_start();
$_SESSION["mail"]=YOUR_MAIL_ADDRESS;
?>
...
Send Mail
PageX.php
<?php
session_start();
<a href="mailto:<?php echo $_SESSION["mail"] ?>?Subject=Hello%20again"
Make just sure that you call this on the top of every pages you want to use this variable.
<?php
session_start();
You can read more here :
http://php.net/manual/fr/reserved.variables.session.php

How to get the details of user who is downloading a file from my webpage before downloading it?

How to get the details of user who is downloading a file from my webpage before downloading it?
Its easy to download a file from webpage and i simply do it with a href tag but what i want is, get the user info like name, email address to my mail before he/she downloads the file. how can i do that?
If you can use some server side technology such as PHP, you could build an HTML form asking for all the data you'd like to gather about the user and then submit to your PHP script.
Your PHP script could store that data inside a DB and then serve the file the user is interested in by using some script like this one:
There is even an example of this on php.net
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
You could even decide whether you allow to download the file or not improving your code with something like this:
<?php
if ( can_this_file_be_downloaded() ) {
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="invoice.pdf"');
readfile("{$_GET['filename']}.pdf");
} else {
die("None shall pass");
}
?>
Edit
If you have more than one file, a very basic approach without the support of a DB would be to setup every download file link to something like: download.php?id=1, download.php?id=2, and so on.
Then in your PHP, to decide which file the user wants to download:
<?php
switch($_GET['id'])
{
case 1:
$filename = "my_file_1.pdf";
break;
case 2:
$filename = "some_file.pdf";
break;
...
}
readfile($filename);
?>
if download is provided to only registered users you can get this stuff from database via user id or user name, otherwise you have to ask them to put these details in text fields.
if you want other details like ip address, browser version etc you can eaisly get it by calling This link

How to send HTML emails with unscrubscribe functionality

My website is able to send emails to people. Now what I would like to do next is be able to send HTML emails to people who subscribe to my mailing just like I would any other normal email and should they want to unscrubscribe, there is a link to do so. I've read up on mail chimp etc but all I want is to send the HTML emails like I would normal emails. Please any guidance would be useful.
With simple HTML you can't send emails, you need PHP or any other Server-Side programming language
Example of HTML email sending with PHP:
<?php
$to = "PUT_RECIPIENT_EMAIL_ADDRESS_HERE";
$subject = "PUT_SUBJECT_HERE";
$mail_body = '<html>
<body bgcolor="#573A28" topmargin="25">
Put HTML content here with variables from PHP if you like
Variable display Example: ' . $subject . '
</body>
</html>';
$headers = "From:youremail#yoursite.comrn";
$headers .= "Content-type: text/htmlrn";
mail($to, $subject, $mail_body, $headers);
?>
to use email subscription you need a table in your database wich stores emails who subscribed to your newsletter, if a user hits "unsubscribe" you have to execute a MySQL query to remove it from your database:
table: subscribed_users(email)
SQL code to add new users to the newsletter:
INSERT INTO subscribed_users VALUES 'put_email_to_subscribe_here'
SQL code to remove users from the newsletter:
DELETE FROM subscribed_users WHERE email = 'put_email_to_unsubscribe_here'
Of course if you don't know how to use php or mysql, you need to study this two languages in order to do your newsletter subscribing.
If you don't want to learn php and mysql you can watch this page, there are some scripts that may help you, but i think you have to learn at least php in order to use them:
http://www.phpkode.com/projects/category/php-newsletter/

CakePHP emails being sent as text instead of html

We recently switched to a new server and now when we send out our email blasts through cakePHP, users who were receiving email as html before are now getting them as code. Any thoughts?
You can configure the format in your controller:
//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'both'; // because we like to send pretty mail
// more code here
$this->Email->send();
If this was triggered by a server move, it's possible that you are missing a file rather than a line of code. In that, case, make sure you have layouts setup for both types of email. Here is the file structure to check:
app/views/layouts/email/
html/
default.ctp
text/
default.ctp
For more from the cookbook:
http://book.cakephp.org/view/1286/Sending-a-basic-message

Sending form without mail client

everubody! can you help me with my trouble? I'm trying to create form for filling resume. User should not use mail client to submit form. How can I realize this idea on javascript or PHP?
First: You need a server based script. Without any server interaction, no mail can be sent.
PHP has a mail() function and it works very well, if your server administrator enabled it.
Very simple example:
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('caffeinated#example.com', 'My Subject', $message);
?>
If mail() is disabled, you need to connect a SMTP server with correct credentials and then you can send mails via this connection.
This function is implemented in the emailer module of phpBB2 e.g.
Good luck!
If the form as a file upload... You can just upload the cv to the webserver and then use your application to send an Email using your account.