attachment with mail()

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!

Moderator: General Moderators

Post Reply
joecamel83
Forum Newbie
Posts: 1
Joined: Wed Apr 20, 2011 2:41 pm

attachment with mail()

Post by joecamel83 »

Hey guys, I have an e-mail script that has contact info and a png image that's in a base64 string posted to the script. How do i get the image as a attachment to the e-mail? the code is below and thanks in advance.

Code: Select all

<?php
   $senderName = $_POST['senderName'];
   $senderEmail =  $_POST['senderEmail'];
   $sendToEmail = "me@example.com";
   $subject = $_POST['emailSubject'];
  $emailMessage = $_POST['emailMessage'];
  $senderPhone = $_POST['senderPhone'];
  $senderStreet = $_POST['senderStreet'];
  $senderCity = $_POST['senderCity'];
  $senderZip = $_POST['senderZip'];
  $base64data =$_POST['base64data'];
  
	   $recipient = "$sendToEmail";
	 
	   $headers = "From: $senderEmail ";
	    
	   $message = "From: $senderName, \nPhone: $senderPhone\nEmail Address: $senderEmail\nStreet: $senderStreet\nCity: $senderCity\nZip: $senderZip\nSubject: $subject\n\nMessage: $emailMessage\n\n $base64data";
	   $message = stripslashes($message);
	 
	   mail($recipient, $subject, $message, $headers)
?>
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Re: attachment with mail()

Post by incubi »

Post Reply