+ Start a Discussion

Outbound email not working

Im having email problems with this code:

public class GLeadExtension {
public Lead aLead ;
public GLeadExtension(ApexPages.StandardController controller) {
aLead = new Lead() ;
public PageReference step1() {
return Page.mhform422;
public PageReference step2() {
return Page.mhformpt2422;
public PageReference step3() {
return Page.mhformpt3422;
public PageReference step4() {
return Page.mhformconfirm;
public PageReference step5(string emailTo) {
return Page.mhformendpage;
public PageReference home() {
return Page.FileNotFound;

public static void send (string emailTo){
String[] toAddresses = new String[] {'margiro@piab.com'};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setSenderDisplayName('Piab Support');
mail.setSubject('New Case Created');
String msg = 'An order has been placed for a conveyor';
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

public PageReference save() {
PageReference pr ;
//ZillowService p = new ZillowService() ;
// make the web service call out
//ZillowTypes.PropertySearchResponse r = p.searchZillow( aLead.Street, aLead.City, aLead.State) ;
// store in custom field
//aLead.Home_Value__c = r.getZEstimateAmount() ;
// insert new record into DB
insert aLead ;
// redirect to the newly inserted lead
// pr = new PageReference( 'http://www.piab.com' );
pr = new PageReference( '/' + aLead.id );
catch( Exception e){
System.debug( '**** Caught Exception' +e ) ;
return pr ;


 I believe that the section that should create an email and send a message to myself after someone fills out a form is in the right place and is linked correctly to the step5 button. When the button is pressed on the site, it redirects to another page(the generic unauthorized page) instead of the mhformendpage like its supposed to.  Anyone see what is wrong with this?