How to send HTML emails with unscrubscribe functionality - html-email

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/

Related

Outlook adding https://na01.safelinks.protection.outlook.com/ to hyperlinks

My email functionality in the current application has a feature that users can use to send document URL's to themselves for future reference or forward the email to known person, which can be used to access the website without needing to login, but recently it has been noticed that the hyperlinks are getting appended by https://na01.safelinks.protection.outlook.com/ in the outlook email and its breaking the scope of the functionality in Chrome and Mozilla when user copy paste's the URL and try to use the hyperlink,It works only fine with IE browser. If I use the email feature and send it to lets say gmail account, the links are intact and works fine when an user clicks the link and it opens in chrome or mozilla. Please suggest how to make this work in outlook as that is the most common email editor that the end users are going to use.
I also had this problem. I don't know how to disable the ATP / Safe Link feature - however, I notice that sending the email as HTML and not plain text will preserve the appearance of the hypertext (even though Outlook still changes the href attribute).
I'm using PHP native email.
First, I change the links - e.g.
$email_body = "<p>" . $message_text . "</p>";
$email_body .= "www.example.com";
Second, I set the headers - e.g.
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; format=flowed; charset=\"utf-8\"; reply-type=original\r\n";
$headers .= "From: =?utf-8?b?" . base64_encode( $from_name ) . "?= <" . $from_a . ">\r\n";
$headers .= "Reply-To: =?utf-8?b?" . base64_encode( $name ) . "?= <" . $email_address . ">\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
Third, I call native PHP mail();
The final result looks like a readable email (even though Outlook still changes href attributes).
For some, it is probably bit of an effort to convert emails from plain text to HTML - however, the benefit is that you have something more consistent looking across most email clients.

HTML format for joomla sendmail

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.

php mail function only working on local server and not on remote server

just as the title I created a simple form in HTML
you can see it at http://thee-l.comuv.com/send.php this sends an email to me with the subject and body text specified I run this on localhost from Apache and I get in my inbox in less than a minute but I then upload it to the remote server the site and it does not email me at all
I have a gmail address so to make it easy I made an outgoing smtp server with smtp2go this was my first php-sent email, I was really happy and right away put it on the remote server and here we are
I am using 000webhost
here is my code
<?php
if ($_POST['submit']){
ini_set("SMTP", "smtp2go.com");
ini_set("smtp_port", 2525);
$to = "lsworkemail112#gmail.com";
$subj = $_POST['topic'];
$body = $_POST['message'];
$header = "From: lsworkemail112#gmail.com";
if (mail($to, $subj, $body, $header))
{
echo "Message sent successfully";
}
else
{
echo "Message sent unsuccessfully";
}
}
else
{
echo "<html>
<form method=\"post\" action=\"send.php\">
Topic: <br/><input type=\"text\" name=\"topic\"/><br/>
Message: <br/><textarea name=\"message\"></textarea><br/>
<input type=\"submit\" value=\"Send\" name=\"submit\"/>
</form>
</html>";
}
?>
I tried clicking on your link, but apparently your website is under review (possibly for mailing too much/suspected of spamming because of your testing?). Even then, linking to a .php page won't show us the code, since the server will execute it and send just the result to the browser. It's better if you copy/paste your code into the question.
Also, as #Computerish said, you may have just run into a limit on your host. How many times have you run your mail() code today?
Check your web hosting company's policies about outgoing mail. There may be a daily limit, a outright ban on it, or it may be an extra service you have to ask for. Almost all hosting companies do something to limit the use of the send() function to prevent spammers from taking advantage of their servers.

How to send form contents anonymously via email

How do you send the content of a website form to an email address without disclosing the email address to the user.
Thanks!
PS: If at all possible, I would like this to be in HTML JavaScript Ok, anything I guess.
Not possible. You can however put a "fake" from header in the mail. You'll only risk it to end up in the junk folder.
HTML doesn't provide any functionality to send mails. You'll really need to do this in the server side. How exactly to do this depends on the server side programming language in question. In PHP for example, you have the mail() function. In Java you have the JavaMail API. And so on.
Regardless of the language used, you'll need a SMTP server as well. It's the one responsible for actually sending the mail. You can use the one from your ISP or a public email provider (Gmail, Yahoo, etc), but you'll be forced to use your account name in the from header. You can also register a domain with a mailbox and just register something like noreply#example.com and use this to send mails from.
Update: JavaScript can't send mails as well. Like HTML it's a client side language. You'll need to do it with a server side language. All JavaScript can do is to dump the entire page content back to the server side. jQuery may be useful in this:
$.post('/your-server-side-script-url', { body: $('body').html(); });
with (PHP targeted example)
$to = 'to#example.com';
$subject = 'Page contents';
$body = $_POST['body']
$headers = prepare_mail_headers();
mail($to, $subject, $body, $headers);
Update 2: if you actually want to hide the to header in the mail, then you'll need to use the bcc (Blind Carbon Copy) instead. This way the recipient addres(ses) will be undisclosed. Only the from, to, cc stays visible.
If you mean doing so on a client side, using mailto: link - you can not.
If you mean any way, yes - you submit the form contents back to your server, and have your back end script send the email.
You can do the form in HTML, but the posting will need to be done in a script. Even if you don't expose the email address, the script can be used to spam that email address. This is why you see captcha being used in such cases.
There are scripts available for most languages. Check to make sure their are no known security problems for the scripts. The original Matt's script in perl had problems, and the Perl community created a more secure version.

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.