Go Back   catalyst2 hosting forums > Support > Scripting Support

Reply
 
Thread Tools Rate Thread Display Modes
Old 29-09-2009, 12:10 PM   #1
alongwor
Junior Member
 
Join Date: Sep 2004
Posts: 13
Linux Hosting, Emailing with sendmail

Hi all,

So my big challenge at the moment is sending out emails under certain circumstances as may have been seen from another thread. there seems to be a lack in definitive information on how to send email out from certain hosting packages. The hope is that this thread becomes a definitive resource with working code.

At the moment I am trying this will the "sendmail" command called from within a perl script (no extra modules are needed for this). the code below is called when I need to sent an email. So far this will send a mail message to a mailbox that is part of my domain but not an external mailbox.

Does anyone know how to modify the following to get the mail beyond my own domain?

Code:
&smtpSendmailCmd ('alongwor@mydomain', 'mailbox@mydomain', 'mailbox@gmail.com', 'Hello world', 'Hello out there');

sub smtpSendmailCmd {
    my ($fromAddr, $toAddr, $ccAddr, $subject, $msg) = @_;
    
    my $SENDMAIL_CMD = "/usr/sbin/sendmail -t";
    unless(open (MAIL, "| $SENDMAIL_CMD")) {
        print "error.\n";
        warn "Error starting sendmail: $!";
    }
    else {
        print MAIL "From: $fromAddr\n";
        print MAIL "To: $toAddr\n";
        print MAIL "CC: $ccAddr\n";
        
        print MAIL "Subject: $subject\n\n";
        print MAIL $msg;
        close(MAIL) || warn "Error closing mail: $!";
    }
}
alongwor is offline   Reply With Quote
Old 29-09-2009, 12:40 PM   #2
Jacob
catalyst2 team
 
Jacob's Avatar
 
Join Date: May 2003
Posts: 1,378
Hi,

What happens when you try and send to an external mailbox?

Regards,

Jacob
Jacob is offline   Reply With Quote
Old 29-09-2009, 01:09 PM   #3
alongwor
Junior Member
 
Join Date: Sep 2004
Posts: 13
I am really not sure, the code does not throw any errors.
Simply that the email is only received at the mailbox for mydomain and not any external domain.
alongwor is offline   Reply With Quote
Old 29-09-2009, 01:13 PM   #4
alongwor
Junior Member
 
Join Date: Sep 2004
Posts: 13
Sorry, scrap what I said...
The mail does arrive if I change the domain... I will check now if my original test was being throw in the spam folder or similar.

So for reference, the original code should work for people using linux hosting.
alongwor is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump