So, I have this php file that takes data form a html form and sends it as a email.
This works great! My form has multiple fields (message, subject, etc.) one of which is "image URL".
In this field ("Image URL") I input the url to a image. Now here is my php email file:
CODE
<?php
require('connect.php');
//change php.ini smtp line
ini_set("SMTP", "smtp.mysite.com");
//standard mail header
$headers = "From: info@mysite.com";
//get message to send
$message = $_GET['message'];
$title = $_GET['subject'];
$sign = $_GET['sign'];
$image = $_GET['image'];
//loop through
for($x=0;$x<count($_GET);$x++)
{
if ($_GET["mail_$x"])
{
//mail setup
$to = $_GET["mail_$x"];
$subject = $title;
$body = $_GET["name_$x"]."
\n\n <img src='http://www.mysite.com/email/uploaded/$image' width='450px'> \n\n
\n\n $message \n\n
$sign ";
mail($to, $subject, $body, $headers);
}
}
echo "All mail has been processed. Cilck <a href='http://www.mysite.com/email/index.php/'>here</a> to go back to mailing list.";
?>
require('connect.php');
//change php.ini smtp line
ini_set("SMTP", "smtp.mysite.com");
//standard mail header
$headers = "From: info@mysite.com";
//get message to send
$message = $_GET['message'];
$title = $_GET['subject'];
$sign = $_GET['sign'];
$image = $_GET['image'];
//loop through
for($x=0;$x<count($_GET);$x++)
{
if ($_GET["mail_$x"])
{
//mail setup
$to = $_GET["mail_$x"];
$subject = $title;
$body = $_GET["name_$x"]."
\n\n <img src='http://www.mysite.com/email/uploaded/$image' width='450px'> \n\n
\n\n $message \n\n
$sign ";
mail($to, $subject, $body, $headers);
}
}
echo "All mail has been processed. Cilck <a href='http://www.mysite.com/email/index.php/'>here</a> to go back to mailing list.";
?>
Now, This's works great! The only issue is: it just says: "img src='http://www.mysite.com/email/uploaded/$image' width='450px'>" (as is should).
Now, I would like to display html content in my emails (such as this image).
I tried this (same issue):
CODE
$body = $_GET["name_$x"]."
\n\n <html><body><center><img src='http://www.mysite.com/email/uploaded/$image' width='450px'></center></body></html> \n\n
\n\n $message \n\n
$sign ";
\n\n <html><body><center><img src='http://www.mysite.com/email/uploaded/$image' width='450px'></center></body></html> \n\n
\n\n $message \n\n
$sign ";
I really don't know how to do this.
Also, I would like to style things with CSS (in my emails). I can add the CSS style to the top, but I don't know how to apply (as html in this email).
How can I do those things? I know the way I am doing the whole email thing is not the most standard way, but its the way I am doing it. I simply want to know how I can incorporate some css and html.
Thanks in advance.
--