- <?php
-
if(isset($_POST['email'])) {
-
-
require_once 'functions.php';
-
// EDIT THE 2 LINES BELOW AS REQUIRED
-
$email_to = "bolarinwaab@gmail.com";
-
$email_subject = "Registration Information";
-
-
-
function died($error) {
-
// your error code can go here
-
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
-
echo "These errors appear below.<br /><br />";
-
echo $error."<br /><br />";
-
echo "Please go back and fix these errors.<br /><br />";
-
die();
-
}
-
-
// validation expected data exists
-
if(
-
!isset($_POST['tittle']) ||
-
!isset($_POST['surname']) ||
-
!isset($_POST['firstname']) ||
-
!isset($_POST['noofchildren']) ||
-
!isset($_POST['email']) ||
-
!isset($_POST['phoneno']) ||
-
!isset($_POST['residentialaddress']) ||
-
!isset($_POST['state']) ||
-
!isset($_POST['country']) ||
-
!isset($_POST['yearofgrad']) ||
-
!isset($_POST['department']) ||
-
!isset($_POST['company']) ||
-
!isset($_POST['attendance'])) {
-
died('We are sorry, but there appears to be a problem with the form you submitted.');
-
}
-
$tittle=$_POST['tittle'];
-
$firstname = $_POST['surname']; // required
-
$lastname = $_POST['firstname']; // required
-
$midname=$_post['middlename'];
-
//$status=$_post['maritalstatus'];
-
$children=$_post['noofchildren'];
-
$email= $_POST['email']; // required
-
$phoneno = $_POST['phone']; // not required
-
$address = $_POST['residentialaddress']; // not required
-
$state = $_POST['state']; // not required
-
$country = $_POST['country']; // not required
-
$yearofgrad = $_POST['yearofgrad']; //required
-
$department = $_POST['department']; // not required
-
$company = $_POST['company']; // not required
-
$attendace = $_POST['attendance']; // not required
-
-
-
$error_message = "";
-
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
-
if(!preg_match($email_exp,$email)) {
-
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
-
}
-
$string_exp = "/^[A-Za-z .'-]+$/";
-
if(!preg_match($string_exp,$firstname)) {
-
$error_message .= 'The Surname you entered does not appear to be valid.<br />';
-
}
-
if(!preg_match($string_exp,$lastname)) {
-
$error_message .= 'The Firstname you entered does not appear to be valid.<br />';
-
}
-
/*if(!preg_match($string_exp,$midname)) {
-
$error_message .= 'The Middlename you entered does not appear to be valid.<br />';
-
}*/
-
/*if(!preg_match($string_exp,$status)) {
-
$error_message .= 'The Marital Status you entered does not appear to be valid.<br />';
-
}*/
-
-
if(!preg_match($string_exp,$address)) {
-
$error_message .= 'The Residential Address you entered does not appear to be valid.<br />';
-
}
-
-
if(!preg_match($string_exp,$department)) {
-
$error_message .= 'The Department name you entered does not appear to be valid.<br />';
-
}
-
if(strlen($company) < 2) {
-
$error_message .= 'The Company Name you entered do not appear to be valid.<br />';
-
}
-
if(strlen($error_message) > 0) {
-
died($error_message);
-
}
-
$email_message = "Form details below.\n\n";
-
-
function clean_string($string) {
-
$bad = array("content-type","bcc:","to:","cc:","href");
-
return str_replace($bad,"",$string);
-
}
-
$email_message .= "Tittle: ".clean_string($tittle)."\n";
-
$email_message .= "Surname: ".clean_string($surname)."\n";
-
$email_message .= "Firstname: ".clean_string($firstname)."\n";
-
$email_message .= "Middlename: ".clean_string($middlename)."\n";
-
//$email_message .= "Marital Status: ".clean_string($maritalstatus)."\n";
-
$email_message .= "No of Children: ".clean_string($noofchildren)."\n";
-
$email_message .= "Email: ".clean_string($email_from)."\n";
-
$email_message .= "Telephone: ".clean_string($phoneno)."\n";
-
$email_message .= "Residential Address: ".clean_string($residentialaddress)."\n";
-
$email_message .= "State: ".clean_string($state)."\n";
-
$email_message .= "Country: ".clean_string($country)."\n";
-
$email_message .= "Year Of Graduation: ".clean_string($yearofgrad)."\n";
-
$email_message .= "Department: ".clean_string($department)."\n";
-
$email_message .= "Company: ".clean_string($company)."\n";
-
$email_message .= "Attendace: ".clean_string($attendace)."\n";
-
-
//Call the email function to perform the mail sending
-
sendGMail($email_message, $email_subject, $email_to);
-
-
// create email headers
-
/*$headers = 'From: '.$email_from."\r\n".
-
'Reply-To: '.$email_from."\r\n" .
-
'X-Mailer: PHP/' . phpversion();
-
@mail($email_to, $email_subject, $email_message, $headers); */
-
-
?>
-
-
<!-- include your own success html here -->
-
-
Thank you for contacting us. We will be in touch with you very soon.
-
-
<?php
-
}
-
?>
I have tried using this code but it seems not to be sending the mail @ all... I need your help guys thanks.
3 1474 Luuk 1,047
Recognized Expert Top Contributor
There is a 'CODE'-tag, please us it..... ;)
At line #3: you write: "require_once 'functions.php';"
The contents of 'functions.php' are needed to know what this line does: line #??: "sendGMail($email_message, $email_subject, $email_to);"
You probably just need to enable error notifications, see here to know why this fails....
- <?php
-
//Function to send email via smtp
-
function sendMail($message, $subject, $recipient)
-
{
-
require_once('class.phpmailer.php');
-
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
-
-
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
-
-
$mail->IsSMTP(); // telling the class to use SMTP
-
-
try {
-
$mail->Host = "mail.yourdomain.com"; // SMTP server
-
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
-
$mail->SMTPAuth = true; // enable SMTP authentication
-
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
-
$mail->Port = 26; // set the SMTP port for the GMAIL server
-
$mail->Username = "yourname@yourdomain"; // SMTP account username
-
$mail->Password = "yourpassword"; // SMTP account password
-
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
-
$mail->SetFrom('name@yourdomain.com', 'First Last');
-
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
-
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
-
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
-
$mail->MsgHTML($message);
-
$mail->Send();
-
echo "Message Sent OK</p>\n";
-
} catch (phpmailerException $e) {
-
echo $e->errorMessage(); //Pretty error messages from PHPMailer
-
} catch (Exception $e) {
-
echo $e->getMessage(); //Boring error messages from anything else!
-
}
-
}
-
//Function to send email via gmail account
-
function sendGMail($message, $subject, $recipient)
-
{
-
require_once('lib/phpmailer/class.phpmailer.php');
-
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
-
$mail->IsSMTP(); // telling the class to use SMTP
-
try {
-
// $mail->Host = "mail.yourdomain.com"; // SMTP server
-
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
-
$mail->SMTPAuth = true; // enable SMTP authentication
-
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
-
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
-
$mail->Port = 465; // set the SMTP port for the GMAIL server
-
$mail->Username = "bolarinwaab@gmail.com"; // GMAIL username
-
$mail->Password = "password"; // GMAIL password
-
$mail->AddAddress($recipient, '');
-
$mail->SetFrom('accoutid@gmail.com', 'name of account');
-
//$mail->AddReplyTo('accountid@gmail.com', 'name of account');
-
$mail->Subject = $subject;
-
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
-
$mail->MsgHTML($message);
-
$mail->Send();
-
} catch (phpmailerException $e) {
-
echo $e->errorMessage(); //Pretty error messages from PHPMailer
-
} catch (Exception $e) {
-
echo $e->getMessage(); //Boring error messages from anything else!
-
}
-
}
-
?>
Hi luuk this is the fuction.php file
Oralloy 988
Recognized Expert Contributor
abramfas,
Will you please use [code] tags, so that we can read your code as you wrote it, rather than with spaces compressed?
This is a BB Code list, so you can see all of the tags and how to use them.
Thanks,
Oralloy
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bob Alston |
last post by:
I am using the Outlook library to send emails from Access. I have
Outlook open and run a program to respond yes to the security question
(Express click Yes).
It seems to take about 5 seconds...
|
by: shubhrarustagi |
last post by:
hi,
I'm a beginner developer and one of my first tasks is to develop
automatic emails application in .net. We need to send automatic emails
to users whose credit cards are expiring, create email...
|
by: =?Utf-8?B?am9lbA==?= |
last post by:
When I posted a comment, I received a message that you had tried 3 times to
send me emails but had been unable to do so. You asked me to solve this
problem. How do I solve this problem?
--
joel
|
by: prasath1984 |
last post by:
hi,
This is prasath i want the code to send bulk emails
|
by: techsri |
last post by:
Hi,
We are going to launch a website which offers free e-learning courses to the users. we are facing some problems to build my site. The problem is about, We want add push email feature to our...
| |
by: palanisiva |
last post by:
Hi, I am using PHP mailer to send out 2 different emails.
The problem I am having is only the first email is ever sent out.
Below is my code. The first email $to but i add two mail id mail not...
|
by: digicrowd |
last post by:
http://bytes.com/images/howtos/applemail_sig_icon.jpg
You can make your emails fancy in Mail.app by using Rich Text formatting or even included Stationery. But, a simple way to send your own HTML...
|
by: rserrador |
last post by:
Hello.
I'm creating a db in access 2007 and i want to have a buton on a report where i can send bcc multiple emails from a query. Can someone help me with the VBA code please.
|
by: londres9b |
last post by:
I want to send multiple emails from php with one unique script.
The emails are from a mysql database table.
How can I achieve this?
|
by: sasasasa |
last post by:
How can I send emails from my Microsoft Outlook through my code.
Dim OlApp As Outlook.Application doesn't even work for me. Any help will be appreciated.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |