Closed liaoqixiang closed 11 months ago
@liaoqixiang initial thoughts relate to network communication being an issue. How are you addressing your email server (e.g. IP vs DNS)? What ports have you exposed?
@merbla Hi there, your thought is I haven't set up the port correctly? there is no setting about port in my docker compose file. I guess it is port 80? my email server is smtp server
Are you resolving the email server via DNS?
@merbla I think it's IP? It is in my company.
@merbla I think I need to check the port tomorrow. Thanks
@merbla I have tried different ports. It seems it's still not working. This web API is using port 80.
@liaoqixiang can you try logging to the Serilog console and also use SelfLog
to expose any errors that might be occurring.
e.g. https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics#selflog
@liaoqixiang if you can post an example of the issue that might help working out the details. My assumption is that it will relate to configuration in Docker.
@merbla
Here are all the settings.
Docker file:
FROM microsoft/aspnetcore:2.0.6 ARG source WORKDIR /app EXPOSE 80 COPY ${source:-obj/Docker/publish} . ENV TZ=NZ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ /etc/timezone ENTRYPOINT ["dotnet", "PPPECSInterface.dll"]
Dokcer-compose file: version: '3.4'
services: pppecsinterface: image: pppecsinterface build: context: ./ECS dockerfile: Dockerfile
Docker-compose-override: version: '3.4'
services: pppecsinterface: environment:
Program.cs
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
// .UseKestrel()
// .UseIISIntegration()
.UseStartup
@merbla I don't see there is a problem of port. It's totally ok if I send email from docker using smtpclient class provided in .net.
Closing this one as stale, hope you were able to find a resolution.
Log.Logger = new LoggerConfiguration() .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Verbose) .WriteTo.Email(new EmailConnectionInfo() { FromEmail = configuration["Email:fromEmail"], EmailSubject = configuration["Email:subjectEmail"], ToEmail = configuration["Email:toEmail"], MailServer = configuration["Email:mailServer"], }, restrictedToMinimumLevel: LogEventLevel.Error) .CreateLogger();
This is my setting. It can send email in local environment but not in docker container. Could anyone have a look to see what is going on?