Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Email with attachment from camera
Started by stany2011 Jul 06 2018 04:21 AM

No replies to this topic
php post network file
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

stany2011

[GLOBAL: userInfoPane.html]
stany2011
  • Enthusiast

  • 34 posts
  • Corona SDK

Hi, i just want to send an email with an image captured by camera, for now the working code is to send e-mails only with text fields, but how i can insert also an image in the e-mail?

?php
$receiverMail	= "mymail@gmail.com";

$name		= ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email		= ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$place		= ltrim(rtrim(strip_tags(stripslashes($_POST['place']))));
$subject	= ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg		= ltrim(rtrim(strip_tags($_POST['msg'])));


$ip		= getenv("REMOTE_ADDR");
$msgformat	= "Email: $email ($ip)\nSubject: $subject\nPlace: $place\n\nDescription: $msg";

// VALIDATION
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
	echo "<h3>Email not sent </h3><p>Try again</p>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
	echo "Wrong e-mail adress";
}
else {
	mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
	echo "<h3>Email sent!</h3><p>thanks for contacting us</p>"; }
?>
local headers = {}
  
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Accept-Language"] = "it-IT"

local body = "name="..var1.."&email="..var2.."&place="..var3.."&subject="..var4.."&msg="..var5
 
local params = {}
params.headers = headers
params.body = body
  
network.request( "http://www.mywebsite.it/send.php", "POST", networkListener, params )

...

local onComplete = function( event )
    print( "Returned from camera view." )
    event.target.alpha = 0
--here's the file
end

media.capturePhoto( { listener = onComplete } )



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: php, post, network, file