Email sent using contact form displays admins "from" address, and not the visitors email - email

This page uses Drupals contact form to send emails: http://www.westlake.school.nz/contact
Problem is, the school staff use outlook. When they recieve email from parents etc, the email comes in as
"From: admin#example.com On Behalf Of
Westlake Boys High School"
In Gmail it comes in correctly such as
from Westlake Boys High School
parentsEmailAddress#yahoo.com
Unfortunately, I cannot tell the entire school staff to stop using Outlook and exchange.
Can Drupals drupal_mail function be altered in order to fix this?
From contact.pages.inc:
drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);

tmsimont explains on this URL (http://api.drupal.org/api/function/drupal_mail#comment-3243) that
the $from parameter will only alter the
From header, not the Sender, Errors-to
or Return-Path.
of the drupal_mail function that is used by contact_mail_page_submit.
with more details (code from the drupal_mail() function)
line 3 - $default_from = variable_get('site_mail', ini_get('sendmail_from'));
line 9 - 'from' => isset($from) ? $from : $default_from,
line 23 - if ($default_from) {
line 24 - // To prevent e-mail from looking like spam, the addresses in the Sender and
line 25 - // Return-Path headers should have a domain authorized to use the originating
line 26 - // SMTP server. Errors-To is redundant, but shouldn't hurt.
line 27 - $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
line 28 - }
line 29 - if ($from) {
line 30 - $headers['From'] = $from;
line 31 - }
line 32 - $message['headers'] = $headers;
So to solve your problem you could implement hook_mail function (http://drupal.org/node/358855#comment-2079266)
More resources can be found here:
1 - http://drupal.org/node/656472
2 - http://drupal.org/node/861562
3 - http://www.nmglc.co.uk/content/overriding-drupals-mail-function

Related

Sending email with Classic ASP through Godaddy

I'm trying to send email using Classic ASP from my website at Godaddy. Unfortunately, the cod I have from 10-15 years ago doesn't work (imagine that! lol). Here's the code. Can someone tell me what has changed since then? desperately await your reply. Thank you!
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = false
.Item(cdoSendUserName) = "email#mywebsite.com"
.Item(cdoSendPassword) = "MyPassword"
.Item(cdoURLProxyServer) = "server:25"
'.Item(cdoSendUsingMethod) = cdoSendUsingPickup
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "relay-hosting.secureserver.net"
.Item(cdoURLGetLatestVersion) = True
.Update
End With
'Create mail object
Set cdoMessage = CreateObject("CDO.Message")
'Apply the settings to the message object then send the email
With cdoMessage
Set .Configuration = cdoConfig
.From = "Support (email#mywebsite)"
.To = "The User (user#email.com)"
.BCC = ""
.Subject = "This is a test email."
.TextBody = "This is a test email. If it were a real email there would be some blah blah blah here! This concludes the test of the Godaddy email message."
.Send
End With
'Cleanup mail objects
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Ok folks. This is for the people that need a guiding hand from time to time. However, make sure you enter the right username and password. When hosting on Godaddy you could have up to three different usernames and passwords. You have your Godaddy account username and password (that's not it!), you have a username and password for Plesk (that's not it either!). Then you have a username and password for your primary website (that's the one you want!). Even though you might have several different websites under your hosting, only one will be the primary. Mine was for the email and password that are associated with that prime website. Once you get this code posted you should be good to go. However, you might have to wait a while in order for it to start working. For me it took about 8 hours for the DNS to catch hold of what I was doing and start sending my emails through. Once it did though, now it works great! Enjoy!
Dim objNewMail
'Your email information
Set objNewMail = Server.CreateObject("CDO.Message")
objNewMail.From = "your-email#this-website.com"
objNewMail.Cc = "your-email#this-website.com"
objNewMail.To = "send-to#their-email.com"
objNewMail.Subject = "This is a test email"
objNewMail.TextBody = "this is a test email"
' GoDaddy SMTP Settings
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="relay-hosting.secureserver.net"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendUserName") = "your-primary-website-username"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendPassword") = "your-primary-website-password"
objNewMail.Configuration.Fields.Update
objNewMail.Send
'After the Send method, NewMail Object become Invalid
Set objNewMail = Nothing

Private only dovecot, local docker configuration for one user fails login for Apple Mail

I'm trying to make a local docker-dovecot machine to archive my e-mails. I would like to query them with Apple Mail. I have a simple ubuntu docker machine (on an VM with parallels, because I'm on a Mac).
I have this local.conf:
# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
listen = *,::
# Protocols we want to be serving.
protocols = imap
# Static passdb.
# This can be used for situations where Dovecot doesn't need to verify the
# username or the password, or if there is a single password for all users:
passdb {
driver = static
args = password=dovecot
}
# Location for users' mailboxes. The default is empty, which means that Dovecot
# tries to find the mailboxes automatically. This won't work if the user
# doesn't yet have any mail, so you should explicitly tell Dovecot the full
# location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
# kept. This is called the "root mail directory", and it must be the first
# path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user#domain, same as %u if there's no domain
# %d - domain part in user#domain, empty if there's no domain
# %h - home directory
#
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# <doc/wiki/MailLocation.txt>
#
mail_location = maildir:/var/mail/%n
# System user and group used to access mails. If you use multiple, userdb
# can override these by returning uid or gid fields. You can use either numbers
# or names. <doc/wiki/UserIds.txt>
# mail_uid = CHANGE_THIS_to_your_short_user_name_or_uid
# mail_gid = admin
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
ssl = no
# Login user is internally used by login processes. This is the most untrusted
# user in Dovecot system. It shouldn't have access to anything at all.
# default_login_user = _dovenull
# Internal user is used by unprivileged processes. It should be separate from
# login user, so that login processes can't disturb other processes.
# default_internal_user = _dovecot
# Setting limits.
default_process_limit = 10
default_client_limit = 50
and I'm getting this from Apple Mail
May 23 07:15:58 Mail[87524] <Debug>: <0x7fe16f021cd0:[Non-authenticated]> Wrote: 1.11 ID ("name" "Mac OS X Mail" "version" "9.3 (3124)" "os" "Mac OS X" "os-version" "10.11.5 (15F34)" "vendor" "Apple Inc.")
May 23 07:15:58 Mail[87524] <Debug>: <0x7fe16f021cd0:[Non-authenticated]> Read: * ID {
name = Dovecot;
}
May 23 07:15:58 Mail[87524] <Debug>: <0x7fe16f021cd0:[Non-authenticated]> Read: 1.11 OK
May 23 07:15:58 Mail[87524] <Debug>: <0x7fe16f021cd0:[Non-authenticated]> Wrote: 3.11 LOGOUT
May 23 07:16:00 Mail[87524] <Debug>: <0x7fe16aa14590:[Disconnected]> Read: * OK [CAPABILITY (
IMAP4REV1,
"LITERAL+",
"SASL-IR",
"LOGIN-REFERRALS",
ID,
ENABLE,
IDLE,
"AUTH=PLAIN",
"AUTH=LOGIN"
)]
May 23 07:16:00 Mail[87524] <Debug>: <0x7fe16aa14590:[Non-authenticated]> Wrote: 1.23 ID ("name" "Mac OS X Mail" "version" "9.3 (3124)" "os" "Mac OS X" "os-version" "10.11.5 (15F34)" "vendor" "Apple Inc.")
May 23 07:16:00 Mail[87524] <Debug>: <0x7fe16aa14590:[Non-authenticated]> Read: * ID {
name = Dovecot;
}
May 23 07:16:00 Mail[87524] <Debug>: <0x7fe16aa14590:[Non-authenticated]> Read: 1.23 OK
May 23 07:16:00 Mail[87524] <Debug>: <0x7fe16aa14590:[Non-authenticated]> Wrote: 3.23 LOGOUT
and this from dovecot (mail.log):
May 23 05:07:22 f8ab3e20742f dovecot: master: Dovecot v2.2.9 starting up (core dumps disabled)
May 23 05:07:22 f8ab3e20742f dovecot: ssl-params: Generating SSL parameters
May 23 05:07:29 f8ab3e20742f dovecot: ssl-params: SSL parameters regeneration completed
May 23 05:07:52 f8ab3e20742f dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=10.211.55.2, lip=172.17.0.2, session=<IJwtbHszbgAK0zcC>
May 23 05:07:54 f8ab3e20742f dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=10.211.55.2, lip=172.17.0.2, session=<qsRNbHszdgAK0zcC>
The output of doveconf -n is (so "disable_plaintext_auth = no" is active):
# 2.2.9: /etc/dovecot/dovecot.conf
# OS: Linux 4.4.8-boot2docker x86_64 Ubuntu 14.04.4 LTS aufs
auth_mechanisms = plain login
default_client_limit = 50
default_process_limit = 10
disable_plaintext_auth = no
listen = *,::
mail_location = maildir:/var/mail/%n
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
args = password=dovecot
driver = static
}
protocols = imap
ssl = no
Any suggestions why this login isn't working?
Thanks!
The solution is to fix and configure the following line correctly (from local.conf):
# mail_uid = CHANGE_THIS_to_your_short_user_name_or_uid
How did I find out? Thanks to #Kondybas for the pointer to try another client. I used Thunderbird and it produced dovecot log entries (why didn't Apple Mail produce these lines? No clue), saying that it couldn't switch to mail_uid user context. I extended dovecot Dockerfile and switched the user appropriately. Afterwards it worked with Thunderbird and then with Apple Mail.

Contact us form with ActionMailer routing error with Rails 4

I'm relatively new to this. I'm trying to route a URL to form and then, that form to shoot off the contact email. This is the error that I'm getting.
And when I rake the routes I see that in fact there is no such this as POST for send_mail. But I'm not sure why there isn't one in the first place. And I'm not sure how to put one in...
Routing Error
No route matches [POST] "/send_mail"
Rails.root: /home/nadia/blog
This is my contact_controller:
1 class ContactController < ApplicationController
2 def new
3 end
4
5 def send_mail
6 name = params[:name]
7 email = params[:email]
8 message = params [:message]
9 ContactUs.contact_email(name, email, message).deliver
10 redirect_to contact_path, notice: 'Message Sent'
11 end
This is my app/mailer/contact_us.rb
1 class ContactUs < ActionMailer::Base
2 default to: "my#email.com"
3 default from: "my#email.com"
4
5 def contact_email (name, email, message)
6 #name = name
7 #email = email
8 #message = message
9
10 mail(from: name, subject: 'Contact')
11 end
12 end
13
Please let me know if there any additional files I can show you
Thank you in advance!
Add this to your routes.rb
post '/send_mail' => 'contact#send_mail'
You should read the Rails routing guide for more info
simply add this in routes.rb
post '/send_mail' => 'contact#send_mail'

Sending email with large body is failing

When sending an email from C# with body being large is resulting in failure in sending email
Mailbox unavailable.
The email is working fine with a smaller body. I am using html body to true property..
Thanks,
Zafar
Code:
using (MailMessage _mailMsg = new MailMessage())
{
_mailMsg.From = new MailAddress(ConfigurationManager.AppSettings["mailFrom"].ToString());
_mailMsg.Body = mail.Body;
_mailMsg.Subject = mail.Subject;
_mailMsg.IsBodyHtml = true;
foreach (string strEmailIds in mailTo)
{
if (strEmailIds != null && strEmailIds != string.Empty && strEmailIds != "")
{
if (!_mailMsg.To.Contains(new MailAddress(strEmailIds)))
_mailMsg.To.Add(new MailAddress(strEmailIds));
}
}
//_mailMsg.CC.Add(ConfigurationManager.AppSettings["mailCC"].ToString());
using (SmtpClient _client = new SmtpClient(ConfigurationManager.AppSettings["Host"].ToString()))
{
if (_mailMsg.To.Count > 0)
{
_client.Send(_mailMsg);
}
else
{
_mailMsg.Subject = "No emails associated with the portfolio: " + account + " Original Email:" + mail.Subject;
_mailMsg.To.Add(new MailAddress(ConfigurationManager.AppSettings["mailSuppotTeam"].ToString()));
_client.Send(_mailMsg);
}
Oke, on thing it could be is that the mail server rejects big messages. Let exclude that one... I assume you have a local smtp mail server installed (check for telnet 127.0.0.1 25 that should give a sort of reply) configure the mail server [ConfigurationManager.AppSettings["Host"]] for 127.0.0.1, can you send big mails now?
If ConfigurationManager.AppSettings["Host"] is already the local SMTP server then:
a) stop that smtp service (Simple Mail Transfer Protocol) for a moment (via the command services.msc)
b) send a small email
c) go to c:\inetpub\mailroot\pickup and edit the message via notepad so that it becomes a BIG email
d) start the smtp service again (services.msc)
The issue was with sending email to cross domain email id and was resulting in the Generic exception
"Mailbox unavailable." May be this is one of the reason behind the above exception.

malformed email subject header when subject > 75 chars using codeigniter email lib

I'm getting some garble in my MIME headers when the subject is over 75 chars.
When the line break is encoded in the header there is an extra line break that is invalid.
Some email gateways are bouncing the email with a "Malformed MIME field: ?= =?utf-8?Q?SUBJECT?=" error.
Does anyone have any experience with utf-8 problems sending emails with CodeIgniter?
-snip-
Return-Path: ***
Subject: =?utf-8?Q?SUBJECT_LINE <--
?= <-- Problem in Subject header
=?utf-8?Q?SUBECT_LINE_2?= <--
To: ***
Reply-To: ***
-snip-
Update:
This has nothing to do with gmail smtp. I have rewritten the question in the hope that it will help someone out in the future.
Apparently this is a known issue, caused by Subject lines > 75 chars.
http://codeigniter.com/forums/viewthread/154493/P15/#925385
The fix was to change the email config like this:
$config['newline'] = "\r\n";
$config['crlf'] = "\n";
Since I myself had this exact problem I will share the solution here since the one shared does not work with version 2.2
Find this piece of code located in system/libraries/Email.php:365
public function subject($subject)
{
$subject = $this->_prep_q_encoding($subject);
$this->_set_header('Subject', $subject);
return $this;
}
With this one
public function subject($subject)
{
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
$this->_set_header('Subject', $subject);
return $this;
}