smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
584 stars 178 forks source link

Sending from different email addresses? #27

Closed qbantek closed 12 years ago

qbantek commented 12 years ago

My application sends notifications from different email addresses (sales@xxx.com, alerts@xxx.com, etc). How can I set a different [To] email (and even a different SMTP server) from code?

smsohan commented 12 years ago

Just set a custom from address in your mailMessage object inside your mailer. Here's an example:

class MyMailer extends MailerBase{ public MailMessage Welcome(){ var mailMessage = ....; mailMessage.From = "sales@seller.com" return mailMessage; } }

qbantek commented 12 years ago

thanks

qbantek commented 12 years ago

Sorry about my previous question. I didn't explain myself properly: since i am using Gmail, I would like to use different credentials for every different account. I can change the FROM field but if I use the same SMTP account the email will still show as originating from another account. Is there a way to specify different SMTP accounts/settings for each message? Thanks a lot!

smsohan commented 12 years ago

Use a smtpclient instance to send your email. That way you can configure it per mail.


Sent from my iPhone S M Sohan

On 2011-09-29, at 4:59 PM, qbantek reply@reply.github.com wrote:

Sorry about my previous question. I didn't explain myself properly: since i am using Gmail, I would like to use different credentials for every different account. I can change the FROM field but if I use the same SMTP account the email will still show as originating from another account. Is there a way to specify different SMTP accounts/settings for each message? Thanks a lot!

Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/27#issuecomment-2244216

ghost commented 10 years ago

This is not working for me at all. I am setting the mailmessage with a different FROM address and then it fails on the send. This email should have the same credentials as the account specified in the web config for the mailer.

smsohan commented 10 years ago

Check the details of the smtpClient you are using. If you are creating the instance, check if it gets the configs applied to it. If you want, for a nominal consultation fee, I can look at your specific code and help you reach a solution.

ghost commented 10 years ago

Thank you! Stepping out for the afternoon, but I will get back with you tomorrow, if that's okay.

On 10/9/2013 3:29 PM, SM Sohan wrote:

Check the details of the smtpClient you are using. If you are creating the instance, check if it gets the configs applied to it. If you want, for a nominal consultation fee, I can look at your specific code and help you reach a solution.

— Reply to this email directly or view it on GitHub https://github.com/smsohan/MvcMailer/issues/27#issuecomment-26000926.

ghost commented 10 years ago

The owner of the exchange server says that the email address is inbound only. Will that make it fail using mvc mailer?

On 10/9/2013 3:29 PM, SM Sohan wrote:

Check the details of the smtpClient you are using. If you are creating the instance, check if it gets the configs applied to it. If you want, for a nominal consultation fee, I can look at your specific code and help you reach a solution.

— Reply to this email directly or view it on GitHub https://github.com/smsohan/MvcMailer/issues/27#issuecomment-26000926.

smsohan commented 10 years ago

That'll make it fail to send a mail anyway.


Sent from my iPhone Sohan SM

On Oct 9, 2013, at 2:37 PM, janessaallen notifications@github.com wrote:

The owner of the exchange server says that the email address is inbound only. Will that make it fail using mvc mailer?

On 10/9/2013 3:29 PM, SM Sohan wrote:

Check the details of the smtpClient you are using. If you are creating the instance, check if it gets the configs applied to it. If you want, for a nominal consultation fee, I can look at your specific code and help you reach a solution.

— Reply to this email directly or view it on GitHub https://github.com/smsohan/MvcMailer/issues/27#issuecomment-26000926.

— Reply to this email directly or view it on GitHubhttps://github.com/smsohan/MvcMailer/issues/27#issuecomment-26006387 .

ghost commented 10 years ago

Okay, thank you so much for the information.

On 10/9/2013 4:38 PM, SM Sohan wrote:

That'll make it fail to send a mail anyway.


Sent from my iPhone Sohan SM

On Oct 9, 2013, at 2:37 PM, janessaallen notifications@github.com wrote:

The owner of the exchange server says that the email address is inbound only. Will that make it fail using mvc mailer?

On 10/9/2013 3:29 PM, SM Sohan wrote:

Check the details of the smtpClient you are using. If you are creating the instance, check if it gets the configs applied to it. If you want, for a nominal consultation fee, I can look at your specific code and help you reach a solution.

— Reply to this email directly or view it on GitHub https://github.com/smsohan/MvcMailer/issues/27#issuecomment-26000926.

— Reply to this email directly or view it on GitHubhttps://github.com/smsohan/MvcMailer/issues/27#issuecomment-26006387

.

— Reply to this email directly or view it on GitHub https://github.com/smsohan/MvcMailer/issues/27#issuecomment-26006501.