I'm using mailgun to sending email, but I'm not able to send more emails (if I duplicate the code below and add change 'to' variable) or I am not able to send cc. If I remove 'cc' from the code, everything works fine, oherwise it throws error pasted below:
$result = $mgClient->sendMessage($domain, array(
'from' => 'Me <me#domain.com>',
'to' => $_POST["customer"]["email"]),
'cc' => 'me#domain.com',
'subject' => 'Confirmation – domain.com',
'html' => $text
));
error:
Fatal error: Uncaught Mailgun\Connection\Exceptions\MissingRequiredParameters: The parameters passed to the API were invalid. Check your inputs! The domain is unverified and requires DNS configuration. Log in to your control panel to view required DNS records.
There is no problem with your code.
The error is for an unverified domain name. You used domain.com as domain, make sure this domain name is verified and valid.
for more read this
Related
I'm sending emails through PHPMailer and I found a specific case when the email address is a non-existing email address that belongs to the sending gateway
[ e.g - gateway email: 1234#1234.com and the email address 0000#1234.com], phpmailer returns the following error: "Recipient address rejected user unknown in virtual mailbox table".
It would be great if a status code might be present there (I want to know if is a hard bounce or a soft bounce) and also, I want to know what kind of other specific cases might occur.
SMTP errors are covered by RFC5321 and related RFCs, and you can see most significant errors codes there. When you get an SMTP error in PHPMailer, the SMTP error code is put in the $error property of the SMTP instance, which is protected, but you can fetch it using getError(). From normal PHP code this would be done with:
$error = $mail->getSMTPInstance()->getError();
The result is an array like this:
[
'error' => $message,
'detail' => $detail,
'smtp_code' => $smtp_code,
'smtp_code_ex' => $smtp_code_ex,
]
The thing that will be of most interest to you is the smtp_code element.
Note that this only applies when you're sending via SMTP; if you're sending via mail(), this won't be populated.
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
I am creating a simple contact us form using Laravel 5.1
public function sendMessage(){
$data = [
'name' => Input::get('name'),
'email' => Input::get('email'),
'subject' => Input::get('subject'),
'body' => Input::get('body')
];
Mail::send('emails.contact',$data, function($message) use($data){
$message->from($data['email'], $data['name']);
$message->to('smartrahat#gmail.com','Mohammed');
$message->subject($data['subject']);
});
Session::flash('success_message','Mail sent successfully!');
return redirect('contact');
}
Everything is working fine but the sender email address is not the one it get from the contact page. The email is sent from the address which I configure in .env
I want to have the email from the sender email address which he filled up contact form. Or, you can say I want to change the header information (only from, I can change other information).
Well Laravel will send the mail through the given smtp server. I guess the smtp server (e.g. google doing this) will not let you change your from address to another address then the account belongs to.
If you want to reply to this address directly in your email programm you can add $message->replyTo($data['email'], $data['name']);.
The $message variable inside the Mail::send() function is a SwiftMailer message instance. Therefore, you can work with headers just like the SwiftMailer documentation shows. Just use $message->getSwiftMessage() to get and manipulate the headers.
Also, you absolutely can change the From header, but if you change it to a different domain, you'll have to deal with phishing warnings in the client. You can resolve that by setting up DKIM and SPF records, and you will need to have access to the DNS settings for the domain to do that.
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 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?