PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi there,
I'm a php newbie and have very little knowledge about php, but I like to learn more about it. I help some friends to build in their website for my excersice. Now I have a question about sending an image to email with php.
I found a tutorial about newsletter, and made a simple newsletter based on the tutorial. I just fill in the list of emails into a .txt database, and fill in a form to send the news. It works fine. But I'd like to have an image on the top of the news. I've tried to figure it out, but no result. I can't find any tutorial about it.
Perhaps anybody can help me? This is the send.php file, where the news will be sent.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$message= ("
<html>
<body bgcolor='#ffffff'>
<br>
'the message goes here. <br>
as you can seen it's the same as a html page <br>
</body>
</html>");
$headers = "From: billgates@satanic.org\r\n";
$headers .= "Content-type: text/html\r\n"; // <------ note the html header type
mail("$recieve_mail", "php and html mail",
"$message",
"$headers"
);
good luck and let us know how it goes
EDIT: it showed my companies name and i missed a few things
I've tried to set the email as html. I think that's the only way. I put the html code "Content-type: text/html\r\n" in the $header.
As you can see in my php file, the message ($message_choice) is the body of the email. The body(message) will be sent to the emails after I submit the message.
Therefore, to get an image on the email's body, I need to type in this code "<img src="path here" />" everytime I submit the news. And one more thing.. because the message will be sent as html, then I have to type <BR> everytime i want to get a new line. I don't think it's efficient..
hehe.. thx.. I just want to make it easy because there will be someone else who fill in the form.
I have no more problem with the image since I send the email with html format. But now the problem is that I can't send the emails to HOTMAIL (and some addresses).. What's wrong with hotmail? I can send emails to yahoo or gmail..