Page 1 of 1

Basic example for sending an email please.

Posted: Tue May 06, 2008 9:56 am
by geddi
Hello,

I have read the docs and I as am new to this and maybe a
bit dumb, I could not really follow how to send the email out.

From the docs I have got this far:

Code: Select all

/* 
*       b_email_act.php
*
*
*  send WAITING CONFIRMATION email  
*/     
   
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 
//Start Swift
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
 
//Create the message
$message =& new Swift_Message("My subject", "My body");
 
//Now check if Swift actually sends it
if ($swift->send(
    $message, new Swift_Address("recipient@address.tld", "Recipient Name"),
    new Swift_Address("sender@address.tld", "My Name")){
        echo "Sent to $sent recipients";
        }
else{
   echo "Failed";
     }  // end else
 
 
I hope its is correct.

But what I don't get is how my message fits in :(

I need to send a confirmation email - so it has to contain a link:

So this is my message:

Code: Select all

 
<html>
<head>
<title>Yodbod.com the Free Ads site</title>
</head>
<body>
<div style = ' 
  width:600px; 
  background-color:white; 
    font-family:Tahoma, Tunga, sans-serif;
    font-size:14;
    text-align:left; 
    font-weight:normal;
    padding:1px;
  margin:1px;
 '>
<p>
<br>
<center><b>Waiting for confirmation on your first advert.</b></center>
<br><br>
Dear $N_contact,
<br><br>
For your security we require that you confirm the advertisement placement by clicking on the 
link below. By confirming your advertisement you also confirm your agreement to the terms of use 
as set out in the terms.php document.
<br><br>
Please activate your advertisement NOW.<br><br>
ACTIVATE: <a href=\"http://www.yodbod.com/activate.php?client=$N_email\">Activate my Advert.</a>
<br><br>
Your email and password are recorderd as follows:<br>
Email: $N_email <br>
Password : $N_pass<br>
<br>
Thanks.<br>
</p>
</div>
</body>
</html>
";
The subject would be "Confirm your free advert".

Would appreciate any help.

Thanks

Re: Basic example for sending an email please.

Posted: Wed May 07, 2008 4:54 am
by chetan1
If u write this code.It would not be wrong and u don't mention here any error which u face.Keep it up and execute it.

Re: Basic example for sending an email please.

Posted: Wed May 07, 2008 5:29 am
by Chris Corbyn
Hint, the "My body" in the first chunk of code you posted *is* the message.