Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Email with attachment

the mail() function

Moderators: macek, egami, gesf

Email with attachment

Postby kralinator » Mon Oct 15, 2012 5:29 am

Hi,
I have a form that get sent to email via PHP and works fine.
I wan to add ability to add attachments and have them sent through too.
I have tried to do this but could not get it working.

So, here is my basic PHP for the form info to be sent through, can anyone modify it to send attachments too?

<?php
$not_to = "phil@kralinator.com";
$not_from = "felinevet.net";
$not_subj = "Online Consultancy Enquiry";

if (isset($_POST['print']) && $_POST['print']!= 'none'){
if (is_array($_POST['print'])){
$pr = implode("\n", $_POST['print']); // format your array for use
} else {

$pr = $_POST['print']; // no array -> print single value

}
}
$nm = trim(strtolower($_POST["Name"]));
$em = trim($_POST["email"]);
$ad = trim($_POST["Address"]);
$vc = trim($_POST["Voucher-Code"]);
$ip = $_SERVER["REMOTE_ADDR"];

$msg = "Enquiry submitted on " . date("l jS F Y H:i:s") . "\n\n";
$msg .= "Name \n" . $nm . "\n\n";
$msg .= "email \n" . $em . "\n\n";
$msg .= "Address \n" . $ad . "\n\n";
$msg .= "Childs Name \n" . $cn . "\n\n";
$msg .= "VOUCHER CODE \n" . $vc . "\n\n";
$msg .= "IP Address\n" . $ip . "\n\n";


$headers = "From: Feline Vet Website <" . $not_from . ">";
mail($not_to, $not_subj, $msg, $headers);

header("location: thankyou.html");
?>
kralinator
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Oct 15, 2012 3:38 am

Re: Email with attachment

Postby seandisanti » Tue Oct 16, 2012 9:24 am

have you tried searching the forum for an answer to your question?

viewtopic.php?f=8&t=17843&p=4393083&hilit=mail+attachment#p4393083
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.