Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2001, 08:20 PM
Doorslammer Doorslammer is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: USA Florida
Posts: 6 Doorslammer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Doorslammer
email with attachment

want to add code to this to send me the file
it's a backup db this works great but I want to add the code so it sends me the new file every night once it makes it
code:--------------------------------------------------------------------------------
mysqldump -u dbuser -pdbuserpassword --opt dbname > /home/youraccount/dbbackup.sql
gzip /home/youraccount/dbbackup.sql
mv /home/youraccount/dbbackup.sql.gz /home/youraccount/dbbackup-`date +%m-%d-%Y`.sql.gz
---------------------------------------------------------------------------------------file name is dbbackup.pl---------------------------------------------------
now I thought adding
sendmail= name@domain
dbbackup-`date +%m-%d-%Y`.sql.gz


would work but not sure
but think I need a right way to do it need to email an attachment


I'm a newbie at this can someone help please


Reply With Quote
  #2  
Old July 1st, 2001, 02:16 PM
CWD_Solutions CWD_Solutions is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 4 CWD_Solutions User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post

Hello you can use the following code to send an email
with an attachment.

Code:
#!/usr/bin/perl

use MIME::Entity;

$message = "Message text here";
    ### Create the top-level, and set up the mail headers:
    $top = MIME::Entity->build(Type    =>"multipart/mixed",
                               From    => "from\@yourdomain.com",
                               To      => "to\@yourdomain.com",
                               Subject => "Your subject here");

    $top->attach(Data=>$message);

    ### Part #2: a GIF file:
    $top->attach(Path        => "/path/to/file/to/attach.zip",
                 Type        => "application/gzip",
                 Encoding    => "binary");


    ### Send it:
    open MAIL, "| /usr/lib/sendmail -t -oi -oem" or die "open: $!";
    $top->print(\*MAIL);
    close MAIL;


Hope this helps.

Regards,
Ray

Reply With Quote
  #3  
Old July 1st, 2001, 04:15 PM
Doorslammer Doorslammer is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: USA Florida
Posts: 6 Doorslammer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Doorslammer
Talking Thank you so much

ok only one question
the backup file gets the name with data every night
so how would I list the in the file to attach ?

would it be like this

### Part #2: a GIF file:
$top->attach(Path => "/home/xxx/dbbackup-`date +%m-%d-%Y`.sql.gz",
Type => "application/gzip",
Encoding => "binary");

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > email with attachment


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT