I can currently send email but for some odd reason the from message looks like this...
noreply=myWebsite.com#mailgun.org <noreply=myWebsite.com#mailgun.org>
But my config file reads as follows...
'driver' => 'mail',
'host' => '',
'port' => 587,
'from' => array('address' => 'noreply#myWebsite.com', 'name' => 'My Website'),
'encryption' => 'tls',
I thought mail was just native php email. I am just trying to understand why it still references mailgun despite the removal of smtp as driver.
What I noticed on the actualy email I receive it says that its from "My Website" followed by "sent by noreply=myWebsite.com#mailgun.org". If I click respond to "My Website" the email address is correct "noreply#mywebsite.com". I just don't understand why I can't get it not to show the sent by message. Any advice?
Related
I'm sending emails with cakephp and I have been testing it with the followign website:
http://spamcheck.postmarkapp.com/
I have had several problems, which one of them was the encoding of the subject.
Right now, that one is solved, following some solutions I've found in the internet. First line of the code is what i'm doing with the subject
Here's my code:
$newsubject='=?UTF-8?B?'.base64_encode($subject).'?=';
$email = new Email('aws');
$email->from(['xxxx#zzzz.zz' => 'test'])
->template('default','confirmation')
->viewVars([
'user_email' => $emailTo,
])
->emailFormat('both')
->to($emailTo)
->subject($newsubject)
->replyTo('support#uphill.pt')
->helpers(['Html', 'Text'])
//->attachments($attachment->path)
->send($message);
After I recieve the email, the subject shows: "=?UTF-8?B?SW5zY3Jpw6fDo28gbm8gZXZlbnRvOiBOYXRpb25hbCBDb25mZXJlbmNlIG9uIEh1bWFuIFBhcGlsbG9tYSBWaXJ1cw==?="
What am I missing?
EDIT:
I'm using Cakephp 3.3 and here's my aws email transporter config
'aws' => [
'transport' => 'aws',
'from' => 'xxxx#zzzzz.z',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
]
Here's my email:
http://pastie.org/private/hzcicqrlzx425ucanxyl5a
Thanks
About the result :
You encoded the email Subject text with base64.
So, you get the encoded text from your Subject plain text.
You should use email Subject as string/plain text. Mail services doesn't decode your custom encode type automatically.
Change your Subject string :
$newsubject='=?UTF-8?B?'.base64_encode($subject).'?=';
#TO
$newsubject=$subject;
Search by typing EmailTransport or Email from config/app.php and check your email configuration is correctly configured.
Her is the details about CakePHP 3.x Email
This is my code:
Mail::send('view',$dataView, function($message) use ($user)
{
$message->from('my_email#gmail.com', 'Myname');
$message->subject('This is title');
$message->to(sender_email#gmail.com, $user->user_username);
});
It works! But When I check sender_email#gmail.com then I see "from email" which I config in .env ( MAIL_USERNAME ), it isn't "from email" in code (my_email#gmail.com), How to I can change it to my_email#gmail.com? Thanks and sorry about my english.
In config/mail.php, around line 58, try changing:
'from' => [
'address' => 'hello#example.com',
'name' => 'Example',
],
to:
'from' => [
'address' => env('MAIL_USERNAME'),
'name' => env('MAIL_USERNAME')
],
You are trying to send emails via dynamic senders which is not allowed by Gmail for preventing spamming mails, so automatically Gmail will change your sender address to your default address.
I guess you're misunderstanding the MAIL_USERNAME which is in your .env file.
So basically, Laravel provides simple solution to send emails via dynamic senders. Lets say you've signed up for MailGun or SendGrid to send mails and MAIL_USERNAME is the username for your mail provider not your sender mail address. (Not Gmail, as Gmail doesn't support dynamic senders. Its good if you're testing your mails.).
so, you're .env will look like this.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=sendgridUsername
MAIL_PASSWORD=sendgridPassword
MAIL_ENCRYPTION=tls
Now, you're eligible to send mails using sendgrid. Now Lets say your domain is example.com so you can use admin#example.com support#example or any email address with your domain to send emails.
To Receive messages either you use webmail or Gmail.
Hope this helps.
I have configured my mail.php config file to send emails using the gmail account.
Everything looks great, but when I try to send email from another account (not the address used in the mail.php config file) I get an email from the address set on the configuration file.
Mail::send('emails.contact_mail', array(
'email' => $fromEmail,
'name' => $user,
'subject' => $subject,
'message' => $message_content,
), function($message)use ($fromEmail,$user,$subject) {
$message->to('s111#gmail.com');
$message->from('test#gmail.com', $user);
$message->subject($subject);
});
It seems like the $message->from doesn't work. I get on the s111#gmail.com an email from the address set in mail.php file and not from test#gmail.com.
Is there any solution? How to change the from address?
You will still use the SMTP servers set in your config file. Setting another 'from' header is theoretically possible, but the GMail SMTP will ignore it unless you set an address that has been added to your Google account.
Solution: either don't use another 'from' address, or add that address to your Google account.
There are a couple things you can try:
$message->replyTo('test#gmail.com', $user);
And to my understanding, the "From: " header in emails is what should determine what it will display as the sender. This may work for changing the "From" header:
$message->getHeaders()->addTextHeader('From', 'Your Name <test#gmail.com>');
I think this is best solution for this question.
We can figure out this as follows:
$message->from('sender#email.com', 'sender_name');
And also we should remove the following code block in config/mail.php.
'from' => [
'address' => 'sender#email.com',
'name' => 'sender_name',
],
of course, this will be working on Laravel Framework.
:)
I have created the Contact Us form using laravel 4
when I set 'app/config/mail.php' file
to my gmail account , like this :
///
'driver' => 'smtp',
host' => 'smtp.gmail.com',
..
......
//
I can send message successfully
but the problem when , I set the 'app/config/mail.php' file
to my own email settings with my host like this :
'driver' => 'smtp',
'host' => 'smtp1.servage.net',
'port' => 25,
'from' => array('address' => 'adress#mywebsite.com', 'name' => 'my_name'),
'encryption' => 'tsl',
'username' => 'my_login#mywebsite.com',
'password' => 'my_pass',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
controller function :
Mail::send('emails.contactus', array('message'=>Input::get('message')), function($message) use ($dataContact){
$message->from($dataContact['emailsender'] , $dataContact['username']);
$message->to('adress#mywebsite.com', 'admin')->replyTo($dataContact['emailsender'] ,$dataContact['username'])->subject('contact request');
});
I send without any error but when I check my inbox , I don't receive any message :(
What is the problem for this ? or is there another solution I can use it ? and thank you :)
This may be a DNS / Email forwarding issue. Try checking your hosting provider which I assume is servage.net. Make sure your DNS settings are properly setup and pointing to the correct nameservers. Also, check to see if your host provider actually provides an email service or simply forwards emails. Once you have the right settings you'll probably have to wait anywhere from an hour to 48 hours to be sure they're set
Your SMTP settings look wrong.
'encryption' => 'tsl',
should be
'encryption' => 'tls',
and if you are using TLS then generally the port is 587, not 25.
I am using this extension.
http://www.yiiframework.com/extension/smtp-mail
I would work properly. But From Email id in mail not set that i have defined in "SetFrom()" function but it takes Gmail username (myemail#gmail.com).
Below is my code for sending mail in my Controller.
$mail = Yii::app()->Smtpmail;
$mail->SetFrom("otherid",$from_name); // This id not coming in my response mail
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->AddAddress($to, "");
config/main.php
'Smtpmail'=>array(
'class' => 'application.extensions.smtpmail.PHPMailer',
'Host' => "smtp.gmail.com",
'Username' => 'myemail#gmail.com',
'Password' => 'password',
'Mailer' => 'smtp',
'Port' => 465,
'SMTPAuth' => true,
'SMTPSecure' => 'ssl'
),
Gmail doesn't seem to allow sending the email via a different email-id if its not registered to the primary gmail account.
When logged in to the primary gmail account -> go to Account tab (top-right).
Search for Add another email address under Send mail as.
Add the new email address there. Confirm the link sent to the additional email account.
On confirmation, your account can send emails from either of the address.
Try the new email address now in $mail->SetFrom("new_gmail_id#gmail.com", $from_name); and it will work fine.
I have tried that and it works. Let us know if you have done all this already.