PHP Error Message
Moderator: General Moderators
thats a very long script!!
where does it go?
i was thinking of using this one, what do you think?
if not, would you recommend one please?
Basic sendmail mailing
where does it go?
i was thinking of using this one, what do you think?
if not, would you recommend one please?
Basic sendmail mailing
Code: Select all
<?php
require('../../Swift.php');
require('../../Swift/Connection/Sendmail.php');
$mailer = new Swift(new Swift_Connection_Sendmail);
//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected())
{
//Sends a simple email
$mailer->send(
'"Joe Bloggs" <joe@bloggs.com>',
'"Your name" <you@yourdomain.com>',
'Some Subject',
"Hello Joe it's only me!"
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
?>Call the script once your form has been submited
Pseudo code
Pseudo code
Code: Select all
if(form_is_submitted)
{
// get user data from form
// format data ready for emailing
// send email
}ok, i'll put it in the same file..
how do you set it up
if this is wrong (and no doubt it is)
can you show me?
how do you set it up
Code: Select all
<?php
if(form_is_submitted)
{
// get user data from form
// format data ready for emailing
// send email
}
?>
<?php
$mailer = new Swift(new Swift_Connection_Sendmail);
//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected())
{
//Sends a simple email
$mailer->send(
'"Joe Bloggs" <joe@bloggs.com>',
'"Joe Bloggs" <joe@bloggs.com>',
'subject',
"message"
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
?>can you show me?
Come on dude, think about it.
Ill give you a start
Ill give you a start
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>We Are Individuals - Application Form Handle</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
// Form Checker 2.0
// First Name
if (strlen($first) > 0)
{
$first = stripslashes($first);
}
// If no name was entered
else
{
$first = NULL;
echo 'You did not enter your <b>First Name</b>';
}
// Last Name
if (strlen($last) > 0)
{
$last = stripslashes($last);
}
// If no name was entered
else
{
$last = NULL;
echo 'You did not enter your <b>Last Name</b>';
}
// Name
$first = '$first';
$last = '$last';
$name = $first . ' ' . $last;
{
echo 'Your name is <b>$name</b>';
}
// Email
if ( !(strlen($email) > 0) )
{
$email = NULL;
echo 'You did not enter your <b>Email</b>';
}
// Gender
if (isset($gender))
{
if ($gender == 'M')
{
$message = 'You chose <b>Male</b>';
}
elseif ($gender == 'F')
{
$message = 'You chose <b>Female</b>';
}
}
// If no gender was entered
else
{
$gender = NULL;
echo 'You did not choose your <b>Gender</b>';
}
// Age
if (strlen($age) > 0)
{
if ($age == '16')
{
$message = 'You chose <b>16</b>';
}
if ($age == '17')
{
$message = 'You chose <b>17</b>';
}
if ($age == '18')
{
$message = 'You chose <b>18</b>';
}
if ($age == '19')
{
$message = 'You chose <b>19</b>';
}
if ($age == '20')
{
$message = 'You chose <b>20</b>';
}
}
// If no age was entered
else
{
$age = NULL;
echo 'You did not choose your <b>Age</b>';
}
// Instrument(s)
if (strlen($instruments) > 0)
{
if ($instruments == 'Bass')
{
$message = 'You chose <b>Bass</b>';
}
if ($instruments == 'Drums')
{
$message = 'You chose <b>Drums</b>';
}
if ($instruments == 'Guitar')
{
$message = 'You chose <b>Guitar</b>';
}
if ($instruments == 'Keyboard')
{
$message = 'You chose <b>Keyboard</b>';
}
if ($instruments == 'Sing')
{
$message = 'You chose <b>Sing</b>';
}
}
// If no instrument(s) entered
else
{
$instruments = NULL;
echo 'You did not choose a(n) <b>Instrument(s)</b>';
}
// Where they live
if (strlen($town) > 0)
{
if ($town == 'braintree')
{
$message = 'You chose <b>Braintree</b>';
}
if ($town == 'chelmsford')
{
$message = 'You chose <b>Chelmsford</b>';
}
if ($town == 'dunmow')
{
$message = 'You chose <b>Dunmow</b>';
}
}
// No town was entered
else
{
echo 'You did not choose a <b>town</b>';
}
// Comments
if (strlen($comments) > 0)
{
$comments = stripslashes($comments);
}
// If no comments were entered
else
{
$comments = NULL;
echo 'You did not enter any <b>Comments</b><br />';
echo 'If you do not want to enter <b>Comments</b>, enter <i>none</i>';
}
// If everything was filled out correctly
if ($first && $last && $email && $gender && $age && $instruments && $town && $comments)
{
echo "Thank you <b>$name</b>, I will reply to you at <i>$email</i>.";
echo $message;
/*
// NOW LETS SEND THIS INFO VIA EMAIL
*/
require('../../Swift.php');
require('../../Swift/Connection/Sendmail.php');
/*
// CREATE AN EMAIL TO SEND
*/
$message = "blah blah blah"; // CHANGE THIS BIT
$mailer = new Swift(new Swift_Connection_Sendmail);
//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected())
{
//Sends a simple email
$mailer->send(
'"Joe Bloggs" <joe@bloggs.com>', // change this
'"Joe Bloggs" <joe@bloggs.com>', // change this
'subject', // change this
$message
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
}
?>
</body>
</html>ok well.. thanks..
just saw this..
i dont understand..
and
does this send an email to both the supplied addresses?
dont i need just one?
just saw this..
Code: Select all
require('../../Swift.php');
require('../../Swift/Connection/Sendmail.php');and
Code: Select all
//Sends a simple email
$mailer->send(
'"Name" <email@email.com>',
'"Name" <email@email.com>',
'subject',
$messagedont i need just one?