Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Sending mail from a Azure Website with php

$
0
0

I have been trying to get a simple form to send a email.   With a php script using azure websites.   I know I could do running a vm but I would like to do with just web page.   I have tested php.  its ok I use a simple script to test...

<?php
 require_once "Mail.php";
 $from = "blakelawless <blake@essexmortgage.com>";
 $to = "blakelawless <blake@essexmortgage.com>";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 $host = "mail.essexmortgage.com";
 $username = "blake@essexmortgage.com";
 $password = "dreams123";
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));
 $mail = $smtp->send($to, $headers, $body);
 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
 ?>

the url is just a simple form to email.

Here is the code behind the form have used on servers before

<?php

 if (empty($_REQUEST['first_name'])){
 	header('location: index.html');exit();}

/* Subject and email variables */

 

                $emailSubject = 'Landing Page Lead Submission';

                $webMaster = 'bill.m.cole@gmail.com';

               

/* Gathering Data Variables */

 

                $user_fname = $_REQUEST ['first_name'];

                $user_lname = $_REQUEST ['last_name'];

                $user_email = $_REQUEST ['email'];

                $area_code = $_REQUEST ['phone_area_code'];

                $prefix = $_REQUEST ['phone_prefix'];

                $suffix = $_REQUEST ['phone_suffix'];
				

               

                $body = '


<h3 style="margin-bottom: 0px;">Landing Page Lead Submission:</h3><hr /><br /><b>Name:</b> '.$user_fname.' '.$user_lname.' <br /><b>Email:</b> '.$user_email.' <br /><b>Phone:</b> ('.$area_code.') '.$prefix.' - '.$suffix.' <br /><b>Message:</b> '.$message.' <br />

';

 

                $headers = "From: ".$user_email."\r\n";

                $headers .= "Content-type: text/html\r\n";

                $success = mail($webMaster, $emailSubject, $body, $headers);
				
				

/* Results rendered as HTML */

 

                $theResults = '

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Thank You</title></head><body><div align="center" style="padding-"><font face="arial, sans-serif" style="font-size:16px;">

                Thank you for your email! You will be redirected back to the site in a few seconds.

<script type="text/javascript"><!--
setTimeout("Redirect()",4000);
function Redirect()
{
  location.href = "http://www.essexmortgage.com";
}
// --></script></div></body></html>

';

echo $theResults;

 

 

?>

I don't mind doing this in asp or .net but I fine with php. My email hosting company allows relaying.

I am computer literate, but what am I missing on this azure website, not using my own webserver. any help would be greatly appreciated.............

Thank you

Now I am in a Azure forum and it will not give me a azure choice of where to post.... Ugggg MS


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>