in src/main/java/org/apache/maven/plugins/announcement/AnnouncementMailMojo.java [299:354]
protected void sendMessage()
throws MojoExecutionException
{
File file = new File( announcementDirectory, announcementFile );
String email = "";
final MailSender ms = getActualMailSender();
final String fromName = ms.getName();
final String fromAddress = ms.getEmail();
if ( fromAddress == null || fromAddress.equals( "" ) )
{
throw new MojoExecutionException( "Invalid mail sender: name and email is mandatory (" + ms + ")." );
}
getLog().info( "Using this sender for email announcement: " + fromAddress + " < " + fromName + " > " );
try
{
MailMessage mailMsg = new MailMessage();
mailMsg.setSubject( getSubject() );
mailMsg.setContent( readAnnouncement( file ) );
mailMsg.setContentType( this.mailContentType );
mailMsg.setFrom( fromAddress, fromName );
for ( Object o1 : getToAddresses() )
{
email = o1.toString();
getLog().info( "Sending mail to " + email + "..." );
mailMsg.addTo( email, "" );
}
if ( getCcAddresses() != null )
{
for ( Object o : getCcAddresses() )
{
email = o.toString();
getLog().info( "Sending cc mail to " + email + "..." );
mailMsg.addCc( email, "" );
}
}
if ( getBccAddresses() != null )
{
for ( Object o : getBccAddresses() )
{
email = o.toString();
getLog().info( "Sending bcc mail to " + email + "..." );
mailMsg.addBcc( email, "" );
}
}
mailer.send( mailMsg );
getLog().info( "Sent..." );
}
catch ( MailSenderException e )
{
throw new MojoExecutionException( "Failed to send email < " + email + " >", e );
}
}