473,763 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending html email using php script

Ann
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.

Thanks,
Ann

Code:
function mail_it($conten t, $subject, $email, $recipient) {
global $attachment_chu nk, $attachment_nam e, $attachment_typ e,
$attachment_sen t, $bcc;
global $db;
global $msgbody;

$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";

$sql_result = mysql_query("SE LECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";

while($rs = mysql_fetch_arr ay($sql_result) )
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n" ;
$headers .= "To: ".$recip."\r\n" ;
$headers .= "Reply-To: ".$email."\r\n" ;
if ($bcc) $headers .= "Bcc: ".$bcc."\r\ n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSI ON."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tbou ndary=\"".$ob." \"\r\n";

$ToName = $rs["Salutation "]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName." ,<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><fo nt color='blue'>Pl ease send an email to <a
href='mailto:ab *@def.com&subje ct='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
multipart/alternative;\r\ n\tboundary=\"" .$ib."\"\r\n\r\ n";
$message .= "\r\n--".$ib."\r\n ";
//$message .= "Content-Type:
text/plain;\r\n\tcha rset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tchar set=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r \n";
$message .= $content."\r\n\ r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_na me && !$attachment_se nt) {
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
$attachment_typ e;\r\n\tname=\" ".$attachment_n ame."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n \tfilename=\"". $attachment_nam e."\"\r\n\r\n ";
$message .= $attachment_chu nk;
$message .= "\r\n\r\n";
$attachment_sen t = 1;
}
$message .= "\r\n--".$ob."--\r\n";

mail($recip, $subject, $message, $headers);
}

}
Jul 17 '05 #1
4 4341
On 2004-10-04, Ann <ns****@yahoo.c om> wrote:
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.


No one likes HTML mails.
Your php knows that.

SCNR :)

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.

--
Marco Dieckhoff
icq# 22243433
GPG Key 0x1A6C95BA -- http://www.frankonia-brunonia.de/keys
Jul 17 '05 #2
Ann a écrit :
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.

Thanks,
Ann

Code:
function mail_it($conten t, $subject, $email, $recipient) {
global $attachment_chu nk, $attachment_nam e, $attachment_typ e,
$attachment_sen t, $bcc;
global $db;
global $msgbody;

$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";

$sql_result = mysql_query("SE LECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";

while($rs = mysql_fetch_arr ay($sql_result) )
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n" ;
$headers .= "To: ".$recip."\r\n" ;
$headers .= "Reply-To: ".$email."\r\n" ;
if ($bcc) $headers .= "Bcc: ".$bcc."\r\ n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSI ON."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tbou ndary=\"".$ob." \"\r\n";

$ToName = $rs["Salutation "]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName." ,<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><fo nt color='blue'>Pl ease send an email to <a
href='mailto:ab *@def.com&subje ct='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
multipart/alternative;\r\ n\tboundary=\"" .$ib."\"\r\n\r\ n";
$message .= "\r\n--".$ib."\r\n ";
//$message .= "Content-Type:
text/plain;\r\n\tcha rset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tchar set=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r \n";
$message .= $content."\r\n\ r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_na me && !$attachment_se nt) {
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
$attachment_typ e;\r\n\tname=\" ".$attachment_n ame."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n \tfilename=\"". $attachment_nam e."\"\r\n\r\n ";
$message .= $attachment_chu nk;
$message .= "\r\n\r\n";
$attachment_sen t = 1;
}
$message .= "\r\n--".$ob."--\r\n";

mail($recip, $subject, $message, $headers);
}

}

Use php.classmailer ; it 's a nice class
Jul 17 '05 #3
> No one likes HTML mails.
Your php knows that.

SCNR :)

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.


Wrong day of the week for a Sermon buddy --

--Wil
Jul 17 '05 #4
la*******@hotma il.com wrote:
No one likes HTML mails.
Your php knows that.

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.


Wrong day of the week for a Sermon buddy --


<obligatory>
- I agree with that guy about HTML emails, but understand that sometimes you
don't have a choice
- Single quotes are usually preferable for PHP strings, as PHP doesn't have to
search them for variables
- Though most browsers parse them okay, you really should use double quotes for
HTML attributes
- *cough*CSS*coug h*
</obligatory>

$content .="<small><fo nt color='blue'>Pl ease send an email to <a
href='mailto:ab *@def.com&subje ct='Re:Email Notifications' to get more
information.</font></small>";

^^^^ this line is suspicious. Unless my NG reader mangled the mailto (which is
entirely possible), you don't have a closing </A> tag, you have a '&' instead of
'?' for the query string, you have a space and a single quote in your subject,
you didn't close your opening A tag with a '>' or even the proper quote
I'd try this:
$content .='<small><font color="blue">Pl ease send an email to <a
href="mailto:ab *@def.com?subje ct='.urlencode( 'Re:Email Notifications') .'">some
address</a> to get more information.</font></small>';

If that doesn't fix it, try viewing source and copying the HTML from the emails
you receive and run it through the w3c html validator (somewhere at w3c.org).

Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4855
by: Bruce | last post by:
Has anyone tried sending web pages containing javascript to another user also using Outlook Express? Mine don't work on the other end - although I'm not sure if this is because they don't have Javascript enabled in MS Explorer 6. I save the entire HTML file + script into my Stationery folder. Then I select Message/New Message Using . Should it work?
4
2972
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text email by creating a text file, with content following certain format, and saving that file into the correct '..\mailroot\pickup' folder, and it is working fine
2
9241
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
6
2422
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
1
2945
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the html formatted emails sending as text/html and were going fine with limited header information. Then we moved the site over to a Dedicated Linux hosting plan. This time, it's PHP 5. Things are bound to not work as expected moving to a new...
4
29110
by: Rajendran | last post by:
I want to send mail through PHP using the MS Exchange server. My php.ini file looks like this (for the MAIL functions) ------- ; For Win32 only. SMTP = exchgserver.test.com smtp_port = 25 ; For Win32 only. sendmail_from = thegoodboy@test.com
7
9830
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to achieve this. Thanks
2
3763
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars = thisForm.elements.value; var arrExcludeVars = strExcludeVars.split(","); for (var j=0; j<arrExcludeVars.length; j++) { if (arrExcludeVars == strToCheck) return true;
3
2711
by: virtualweb | last post by:
Hello: I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp. For some reason instead of receiving the email with the HTML showing a link that will open up my PopUp... Im getting all the HTML tags and javasacript code printed on my email. What am I doing wrong..?? Here is the code:
9
8255
by: neovantage | last post by:
hey geeks, I have a small mail script which will cause a PHP script to send a receipt upon clicking the submit button, by an HTML mail. This mail contains special characters, namely 'å', 'ä' and 'ö'. Whatever I try, I can't get these characters to display properly everywhere. In some email clients, these characters show up just fine, whereas in others they show up as question marks or kinda boxes. I've tried sending the mail as UTF-8, as...
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9389
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9828
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8825
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5271
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.