Advertisement
Guest User

Untitled

a guest
Feb 16th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. ## Relay mails to an external SMTP server
  2.  
  3. This shows you how to send mails from a - in this case virtual debian server
  4. inside VirtualBox - server to an external SMTP server. You can use your own
  5. server, Gmail or any other SMTP server you have access to.
  6.  
  7. This can then be used to send mail from PHP, Rails, Python, console or whatever you like.
  8.  
  9. The steps are for a debian wheezy server.
  10.  
  11. **You will need:**
  12. * a username and password for the smtp server
  13. * the address and port of the smtp server
  14. * a (virtual) server
  15.  
  16. ### Install sSMTP
  17.  
  18. sudo apt-get install ssmtp
  19.  
  20. ### Configure sSMTP
  21.  
  22. Open the config file and make it look like the following. Change all uppercase strings
  23. (except the YES and NOs) to the your personal login, server, etc. I did not replace
  24. the port, as it should be the standard of 587.
  25.  
  26. sudo nano /etc/ssmtp/ssmtp.conf
  27.  
  28. #
  29. # Config file for sSMTP sendmail
  30. #
  31. # The person who gets all mail for userids < 1000
  32. # Make this empty to disable rewriting.
  33. root=YOUR_EMAIL_ADDRESS_HERE
  34.  
  35. # The place where the mail goes. The actual machine name is required no
  36. # MX records are consulted. Commonly mailhosts are named mail.domain.com
  37. mailhub=YOUR_SMTP_SERVER_HERE:587
  38.  
  39. # Where will the mail seem to come from?
  40. # Set it to something like yourdomainname.com
  41. rewriteDomain=YOUR_DOMAIN_NAME_HERE
  42.  
  43. # The full hostname
  44. hostname=YOUR_EMAIL_ADDRESS
  45.  
  46. # Do not replace the YES ;)
  47. UseSTARTTLS=YES
  48.  
  49. AuthUser=YOUR_USERNAME_FOR_THE_SMTP_SERVER
  50. AuthPass=YOUR_PASSWORD_FOR_THE_SMTP_SERVER
  51.  
  52. # Are users allowed to set their own From: address?
  53. # YES - Allow the user to specify their own From: address
  54. # NO - Use the system generated From: address
  55. FromLineOverride=YES
  56.  
  57. Save the file with ctrl+x
  58.  
  59. You can configure forwarding of mails in the following file. You don't need to if you
  60. don't want/need forwarding.
  61.  
  62. sudo nano /etc/ssmtp/revaliases
  63.  
  64. # sSMTP aliases
  65. #
  66. # Format: local_account:outgoing_address:mailhub
  67. #
  68. # Example: root:your_login@your.domain:mailhub.your.domain[:port]
  69. # where [:port] is an optional port number that defaults to 25.
  70.  
  71. root:YOUR_EMAIL_ADDRESS:YOUR_SMTP_SERVER_HERE:587
  72.  
  73. Save it with ctrl+x
  74.  
  75. ### Test it
  76.  
  77. You can test it with the following command on the commandline:
  78.  
  79. sudo ssmtp YOUR_EMAIL_HERE
  80.  
  81. Type some words, add a new line and close with (double) `crtl+d` to send the message.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement