Jump to content

Mail from contact form -SMTP method - how to change "from" field


Recommended Posts

A tricky problem with my mail system:

I'm sending mails from my shop to customers via a personal secured smtp server.
When the shop sends an email to me (shop owner), composed by a client in the contact form, the mail is sent via my smtp server, but the sender appears to be the customer who composed the email, and the sender's address is the one declared in the form by the sender.

Here is the problem: my smtp server does not accept foreign senders (foreign mails in the sender or reply-to fields), but only recognized authenticated users.

So, where is the code (in what php file), that compose the mails from contact form, because I need to modify the sender field, to be always my shop's address (the customer's mail address will still be announced in the body of the email).

contact.php in classes does not seems to contain the sending code (I'm not a php programmer but I do have some programing knowledge and I'm able to modify a variable or things like these)

Thank you very much,

Link to comment
Share on other sites

Ok I don't know if it is the best way of solving it but here is what I did:

In contact-form.php (root folder of the site) I've changed the line:


if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))


with:


if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, '[email protected]', (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))


(change whatever applies instead of [email protected])

Thanks,
  • Like 1
Link to comment
Share on other sites

  • 5 years later...

Nick_escu, thanks very much for highlighting this. I appreciate this message is from 2010 so a long time ago and things have changed.

 

It's 2016 and the SwiftMailer is still in an issue with Prestashop which is frankly unbelievable.

 

A customer of mine, admittedly using 1.5.3, was having the issue. We purchased Bellini's Swift Mailer Upgrade (https://www.bellini-services.com/shop/modifications/39-swift-mailer-upgrade-better-support-for-ssltls.html?) which figured out the order email issues. Unfortunately I still couldn't get the contact form to work due to relay issues, I suspect. So by going on Nick_escu's post, I was able to sort it by manually placing the email address in the file.

 

However, things have changed a lot since Nick_escu's post - the contact form stuff now resides in 

/controllers/front/ContactController.php

where you'll find this line:

if (Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form'),
						$mail_var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),

as Nick_escu says, change 

$from

to:

'[email protected]'

Hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...