Changeset 87


Ignore:
Timestamp:
03/19/09 16:54:46 (15 years ago)
Author:
nanardon
Message:
  • fix mail encoding
  • don't hardcode smtp server
  • warn (in log then) is mail cannot be sent
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Model/Vote.pm

    r86 r87  
    3838 
    3939sub db { $_[0]->{db} } 
     40 
     41sub mail_header { 
     42    return( 
     43        'Content-Type' => 'text/plain; charset=UTF-8; format=flowed', 
     44        'Content-Transfer-Encoding' => '8bit', 
     45        'X-Epoll-version' => $Vote::VERSION, 
     46    ); 
     47} 
    4048 
    4149sub random_string { 
     
    769777 
    770778    # TODO complete this properly: 
    771     my $mailer = new Mail::Mailer 'smtp', Server => 'mailhost'; 
     779    my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost'); 
    772780    $mailer->open({ 
    773781        From => $voteinfo->{owner}, 
     
    775783        Subject => 'Invitation a voter: ' . $voteinfo->{label}, 
    776784        'X-Epoll-poll' => $id, 
    777         'X-Epoll-version' => $Vote::VERSION, 
     785        mail_header(), 
    778786    }); 
    779787    print $mailer <<EOF; 
    780 Vous etes convie à participer a ce vote: 
     788Vous êtes convié à participer a ce vote: 
     789 
     790-------- 
    781791$voteinfo->{label} 
    782  
    783 a l'adresse: 
     792-------- 
     793 
     794à l'adresse: 
    784795 
    785796$mailinfo->{voteurl} 
     
    788799Votre mot de passe est: $passwd 
    789800 
    790 Conserver precieusement ces identifiants, il ne vous seront pas redonner. 
     801Conserver précieusement ces identifiants, il ne vous seront pas retransmit. 
    791802 
    792803Cordialement. 
    793804EOF 
    794     $mailer->close; 
     805    $mailer->close or warn "couldn't send whole message: $!\n"; 
    795806 
    796807    $self->db->commit; 
     
    854865 
    855866    $addreq->execute($reqid, $info{label}, $info{mail}); 
    856     my $mailer = new Mail::Mailer 'smtp', Server => 'mailhost'; 
     867    my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost'); 
    857868    $mailer->open({ 
    858869        From => 'Voting system <nomail@nomail.com>', # TODO allow to configure this 
    859870        To => $info{mail}, 
    860871        Subject => 'Votre nouveau vote', 
     872        mail_header(), 
    861873    }); 
    862874    print $mailer <<EOF; 
     
    868880$info{url}/$reqid 
    869881 
    870 A bientot 
     882A bientÃŽt 
    871883EOF 
    872     $mailer->close; 
     884    $mailer->close 
     885        or warn "couldn't send whole message: $!\n"; 
    873886    $self->db->commit; 
    874887    1; 
  • trunk/vote.yml.example

    r5 r87  
    22name: Vote 
    33db: dbname=vote 
     4-- The smtp serveur to use 
     5smtp: 
Note: See TracChangeset for help on using the changeset viewer.