#1 2016-11-04 16:35:16

bpeikes
Member
Registered: 2016-10-29

From email header on scheduled reports

Is there a way to change who the From: is in emails sent via scheduled reports? It seems to default to the person who scheduled it. We would rather it be from a special account. Changing the From: header in such a way that it does not match the SMTP user (our SMTP gateway requires credentials), can cause problems. It also makes it difficult for people receiving the report to know that it was generated by our system, and not sent directly from a particular user.

Offline

#2 2016-11-06 14:59:47

karolina
Member
Registered: 2014-08-09

Re: From email header on scheduled reports

Yes. You need to configure mail.cf (/etc/mail/mail.cf) in a way similar to one below:

  
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <smtp>
      <host>mail.myhost.com</host>
      <port>587</port>
      <username>rs@myhost.com</username>
      <password>my_password</password>
      <ssl>false</ssl>
      <tls>
         <enable>true</enable>
         <require>false</require>
      </tls>
   </smtp>
   <mail>
      <sender>rs@myhost.com</sender>
     <forceSender>true</forceSender>
      <encryptionPolicy>allow_mixed</encryptionPolicy>
   </mail>
</configuration>

Users will see 'rs@myhost.com' as the sender.
Note that ssl settings and port numbers may be different in your case.

After saving the file, make sure to reload the configuration by opening the terminal (Ctrl + Alt + T) and entering 'config reload' command.

Let me know if this solved the problem.

Offline

#3 2016-11-07 14:22:16

bpeikes
Member
Registered: 2016-10-29

Re: From email header on scheduled reports

I made the change, but now I'm not receiving emails. What's the best way to check the log to see what the problem is? Even switching back to our old configuration doesn't seem to fix the issue.

Offline

#4 2016-11-07 14:34:22

bpeikes
Member
Registered: 2016-10-29

Re: From email header on scheduled reports

Below is the error I now see in the log, and here is the configuration (password, username and host has been changed)
Also note that previewing the report works fine.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <smtp>
        <host>MAIL_HOST</host>
        <port>465</port>
        <username>MAIL_USER</username>
        <password>MAIL_USER_PWD</password>
        <ssl>true</ssl>
        <tls>
            <enable>false</enable>
            <require>false</require>
        </tls>
    </smtp>
    <mail>
      <sender>MAIL_SENDER</sender>
      <encryptionPolicy>allow_mixed</encryptionPolicy>
    </mail>
</configuration>

Here is the log message:


07-Nov-2016 09:30:26.457 WARNING [pool-7-thread-1] net.datenwerke.rs.core.service.mail.MailServiceImpl$1.run Mail could not be send
net.datenwerke.rs.core.service.mail.exceptions.MailerRuntimeException: Mail could not be send
    at net.datenwerke.rs.core.service.mail.MailServiceImpl$MailSupervisorImpl.handleException(MailServiceImpl.java:58)
    at net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:243)
    at net.datenwerke.rs.core.service.mail.MailServiceImpl$1.run(MailServiceImpl.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not prepare statement
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
    at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:445)
    at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:50)
    at net.datenwerke.rs.utils.simplequery.byatt.QueryByAttProcessor.process(QueryByAttProcessor.java:99)
    at net.datenwerke.rs.utils.simplequery.byatt.QueryByAttInterceptor.invoke(QueryByAttInterceptor.java:24)
    at net.datenwerke.rs.terminal.service.terminal.vfs.hooks.TreeBasedVirtualFileSystem.getNodeByLocation(TreeBasedVirtualFileSystem.java:107)
    at net.datenwerke.rs.terminal.service.terminal.vfs.hooks.TreeBasedVirtualFileSystem.getLocation(TreeBasedVirtualFileSystem.java:60)
    at net.datenwerke.rs.terminal.service.terminal.vfs.VirtualFileSystemDeamon.getLocation(VirtualFileSystemDeamon.java:143)
    at net.datenwerke.rs.terminal.service.terminal.vfs.VirtualFileSystemDeamon.getAbsoluteLocation(VirtualFileSystemDeamon.java:105)
    at net.datenwerke.rs.terminal.service.terminal.vfs.VirtualFileSystemDeamon.getLocation(VirtualFileSystemDeamon.java:81)
    at net.datenwerke.rs.terminal.service.terminal.vfs.hookers.VfsObjectResolver.getParentLocation(VfsObjectResolver.java:81)
    at net.datenwerke.rs.terminal.service.terminal.vfs.hookers.VfsObjectResolver.consumes(VfsObjectResolver.java:23)
    at net.datenwerke.rs.terminal.service.terminal.objresolver.ObjectResolverDeamon.getObjects(ObjectResolverDeamon.java:60)
    at net.datenwerke.rs.terminal.service.terminal.objresolver.ObjectResolverDeamon.getObjects(ObjectResolverDeamon.java:88)
    at net.datenwerke.rs.terminal.service.terminal.objresolver.ObjectResolverDeamon.getObjects(ObjectResolverDeamon.java:84)
    at net.datenwerke.rs.terminal.service.terminal.TerminalServiceImpl.getObjectsByLocation(TerminalServiceImpl.java:100)
    at net.datenwerke.rs.terminal.service.terminal.TerminalServiceImpl.getObjectByLocation(TerminalServiceImpl.java:111)
    at net.datenwerke.rs.configservice.service.configservice.FileServerConfigStore.loadConfig(FileServerConfigStore.java:28)
    at net.datenwerke.rs.configservice.service.configservice.ConfigServiceImpl.getConfig(ConfigServiceImpl.java:117)
    at net.datenwerke.rs.configservice.service.configservice.ConfigServiceImpl.getConfig(ConfigServiceImpl.java:84)
    at net.datenwerke.security.service.crypto.CryptoServiceImpl.getCredentialProviders(CryptoServiceImpl.java:96)
    at net.datenwerke.security.service.crypto.CryptoServiceImpl.getUserCryptoCredentials(CryptoServiceImpl.java:61)
    at net.datenwerke.rs.core.service.mail.MailServiceImpl.sendMailSync(MailServiceImpl.java:127)
    ... 4 more
Caused by: org.hibernate.exception.JDBCConnectionException: could not prepare statement
    at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:48)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1928)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1897)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1875)
    at org.hibernate.loader.Loader.doQuery(Loader.java:919)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
    at org.hibernate.loader.Loader.doList(Loader.java:2611)
    at org.hibernate.loader.Loader.doList(Loader.java:2594)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2423)
    at org.hibernate.loader.Loader.list(Loader.java:2418)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:220)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
    at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:567)
    at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:436)
    ... 25 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
    at com.mysql.jdbc.Util.getInstance(Util.java:387)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:917)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
    at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1235)
    at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1230)
    at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4132)
    at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4101)
    at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:469)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
    ... 42 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 519,827,731 milliseconds ago.  The last packet sent successfully to the server was 519,827,732 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at sun.reflect.GeneratedConstructorAccessor300.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3652)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2460)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:1418)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2116)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1899)
    ... 39 more
Caused by: java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3634)

Offline

#5 2016-11-07 14:44:01

bpeikes
Member
Registered: 2016-10-29

Re: From email header on scheduled reports

Never mind, a restart of the server seemed to fix the issue. One more question about the email though. Can we set the full "from", i.e.
"Report Server" report_server@trlm.com

Offline

#6 2016-11-07 15:10:03

karolina
Member
Registered: 2014-08-09

Re: From email header on scheduled reports

I'll see if this is possible, as I'd like to have it configured in a similar way.
It just may take some time :-)

karolina

Offline

#7 2019-02-04 08:09:21

eduardo
Administrator
Registered: 2016-11-01
Website

Re: From email header on scheduled reports

Hi karolina & bpeikes,

I raised issue RS-3300 for this (allow to specify sender name along with sender email address in mail.cf). It will be probably available with reportserver 3.0.6. I will let you know here when I have more information on this.

Regards,
Eduardo

Offline

#8 2019-02-04 09:12:20

eduardo
Administrator
Registered: 2016-11-01
Website

Re: From email header on scheduled reports

Hi,

we added a configuration option to mail.cf: senderName. When this is set, the sender name will appear as a sender. E.g.: "ReportServer" report_server@trlm.com

Example configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <smtp>
      <host>mail.infofabrik.net</host>
      <port>25</port>
      <!--<username>rs@infofabrik.net</username>
      <password></password>
      -->
      <ssl>false</ssl>
      <tls>
         <enable>false</enable>
         <require>false</require>
      </tls>
   </smtp>
   <mail>
      <sender>rs@infofabrik.net</sender>
      <senderName>ReportServer</senderName>
      <forceSender>false</forceSender>
      <encryptionPolicy>allow_mixed</encryptionPolicy>
   </mail>
</configuration>

This will be available in ReportServer 3.0.6.

Regards,
Eduardo

Offline

#9 2019-03-13 10:46:07

eduardo
Administrator
Registered: 2016-11-01
Website

Re: From email header on scheduled reports

Hi,

ReportServer 3.0.6 is released and this is supported in this version, please check the release notes: https://reportserver.net/releasenotes/RS3.0.6.html

RS-3300    Improvement    Allow to specify default sender name along with default sender email address in mail.cf

Regards,
Eduardo

Offline

Board footer

Powered by FluxBB